Compare commits
3 commits
9abf1b65ab
...
3d504e5059
Author | SHA1 | Date | |
---|---|---|---|
3d504e5059 | |||
cf26b77fdf | |||
9785b9856c |
4 changed files with 44 additions and 14 deletions
|
@ -18,6 +18,7 @@ crate::strenum! {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Link : crate::Base {
|
pub trait Link : crate::Base {
|
||||||
|
fn link_type(&self) -> Field<LinkType> { Err(FieldErr("type")) }
|
||||||
fn href(&self) -> &str;
|
fn href(&self) -> &str;
|
||||||
fn rel(&self) -> Field<&str> { Err(FieldErr("rel")) }
|
fn rel(&self) -> Field<&str> { Err(FieldErr("rel")) }
|
||||||
fn media_type(&self) -> Field<&str> { Err(FieldErr("mediaType")) } // also in obj
|
fn media_type(&self) -> Field<&str> { Err(FieldErr("mediaType")) } // also in obj
|
||||||
|
@ -29,6 +30,7 @@ pub trait Link : crate::Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LinkMut : crate::BaseMut {
|
pub trait LinkMut : crate::BaseMut {
|
||||||
|
fn set_link_type(self, val: Option<LinkType>) -> Self;
|
||||||
fn set_href(self, href: &str) -> Self;
|
fn set_href(self, href: &str) -> Self;
|
||||||
fn set_rel(self, val: Option<&str>) -> Self;
|
fn set_rel(self, val: Option<&str>) -> Self;
|
||||||
fn set_media_type(self, val: Option<&str>) -> Self; // also in obj
|
fn set_media_type(self, val: Option<&str>) -> Self; // also in obj
|
||||||
|
@ -56,6 +58,7 @@ impl Link for serde_json::Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crate::getter! { link_type -> type LinkType }
|
||||||
crate::getter! { rel -> &str }
|
crate::getter! { rel -> &str }
|
||||||
crate::getter! { mediaType -> &str }
|
crate::getter! { mediaType -> &str }
|
||||||
crate::getter! { name -> &str }
|
crate::getter! { name -> &str }
|
||||||
|
@ -80,6 +83,7 @@ impl LinkMut for serde_json::Value {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
crate::setter! { link_type -> type LinkType }
|
||||||
crate::setter! { rel -> &str }
|
crate::setter! { rel -> &str }
|
||||||
crate::setter! { mediaType -> &str }
|
crate::setter! { mediaType -> &str }
|
||||||
crate::setter! { name -> &str }
|
crate::setter! { name -> &str }
|
||||||
|
|
|
@ -92,7 +92,8 @@ pub trait Object : Base {
|
||||||
fn summary(&self) -> Field<&str> { Err(FieldErr("summary")) }
|
fn summary(&self) -> Field<&str> { Err(FieldErr("summary")) }
|
||||||
/// One or more "tags" that have been associated with an objects. A tag can be any kind of Object
|
/// One or more "tags" that have been associated with an objects. A tag can be any kind of Object
|
||||||
/// The key difference between attachment and tag is that the former implies association by inclusion, while the latter implies associated by reference
|
/// The key difference between attachment and tag is that the former implies association by inclusion, while the latter implies associated by reference
|
||||||
fn tag(&self) -> Node<Self::Object> { Node::Empty }
|
// TODO technically this is an object? but spec says that it works my reference, idk
|
||||||
|
fn tag(&self) -> Node<Self::Link> { Node::Empty }
|
||||||
/// Identifies one or more links to representations of the object
|
/// Identifies one or more links to representations of the object
|
||||||
fn url(&self) -> Node<Self::Link> { Node::Empty }
|
fn url(&self) -> Node<Self::Link> { Node::Empty }
|
||||||
/// Identifies an entity considered to be part of the public primary audience of an Object
|
/// Identifies an entity considered to be part of the public primary audience of an Object
|
||||||
|
|
|
@ -57,9 +57,13 @@ impl Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn nodeinfo(domain: &str) -> reqwest::Result<NodeInfoOwned> {
|
pub async fn nodeinfo(domain: &str) -> reqwest::Result<NodeInfoOwned> {
|
||||||
reqwest::get(format!("https://{domain}/nodeinfo/2.0.json"))
|
match reqwest::get(format!("https://{domain}/nodeinfo/2.0.json")).await {
|
||||||
|
Ok(res) => res.json().await,
|
||||||
|
// ughhh pleroma wants with json, key without
|
||||||
|
Err(_) => reqwest::get(format!("https://{domain}/nodeinfo/2.0.json"))
|
||||||
.await?
|
.await?
|
||||||
.json()
|
.json()
|
||||||
.await
|
.await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use apb::{ActivityMut, Object, ObjectMut};
|
use apb::{ActivityMut, DocumentMut, Object, ObjectMut};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use crate::{prelude::*, DEFAULT_COLOR};
|
use crate::{prelude::*, DEFAULT_COLOR};
|
||||||
|
|
||||||
|
@ -131,10 +131,31 @@ pub fn ConfigPage(setter: WriteSignal<crate::Config>) -> impl IntoView {
|
||||||
<input class="w-100" type="submit" value="submit"
|
<input class="w-100" type="submit" value="submit"
|
||||||
on:click=move|e| {
|
on:click=move|e| {
|
||||||
e.prevent_default();
|
e.prevent_default();
|
||||||
let display_name = display_name_ref.get().map(|x| x.value()).unwrap_or("".into());
|
let display_name = display_name_ref.get()
|
||||||
let avatar = avatar_url_ref.get().map(|x| x.value()).unwrap_or("".into());
|
.map(|x| x.value())
|
||||||
let banner = banner_url_ref.get().map(|x| x.value()).unwrap_or("".into());
|
.filter(|x| !x.is_empty());
|
||||||
let summary = summary_ref.get().map(|x| x.value()).unwrap_or("".into());
|
|
||||||
|
let summary = summary_ref.get()
|
||||||
|
.map(|x| x.value())
|
||||||
|
.filter(|x| !x.is_empty());
|
||||||
|
|
||||||
|
let avatar = avatar_url_ref.get()
|
||||||
|
.map(|x| x.value())
|
||||||
|
.filter(|x| !x.is_empty())
|
||||||
|
.map(|x|
|
||||||
|
apb::new()
|
||||||
|
.set_document_type(Some(apb::DocumentType::Image))
|
||||||
|
.set_url(apb::Node::link(x))
|
||||||
|
);
|
||||||
|
|
||||||
|
let banner = banner_url_ref.get()
|
||||||
|
.map(|x| x.value())
|
||||||
|
.filter(|x| !x.is_empty())
|
||||||
|
.map(|x|
|
||||||
|
apb::new()
|
||||||
|
.set_document_type(Some(apb::DocumentType::Image))
|
||||||
|
.set_url(apb::Node::link(x))
|
||||||
|
);
|
||||||
|
|
||||||
let id = auth.userid.get_untracked().unwrap_or_default();
|
let id = auth.userid.get_untracked().unwrap_or_default();
|
||||||
let Some(me) = CACHE.get(&id) else {
|
let Some(me) = CACHE.get(&id) else {
|
||||||
|
@ -147,10 +168,10 @@ pub fn ConfigPage(setter: WriteSignal<crate::Config>) -> impl IntoView {
|
||||||
.set_to(apb::Node::links(vec![apb::target::PUBLIC.to_string(), format!("{id}/followers")]))
|
.set_to(apb::Node::links(vec![apb::target::PUBLIC.to_string(), format!("{id}/followers")]))
|
||||||
.set_object(apb::Node::object(
|
.set_object(apb::Node::object(
|
||||||
(*me).clone()
|
(*me).clone()
|
||||||
.set_name(Some(&display_name))
|
.set_name(display_name.as_deref())
|
||||||
.set_summary(Some(&summary))
|
.set_summary(summary.as_deref())
|
||||||
.set_icon(apb::Node::link(avatar))
|
.set_icon(apb::Node::maybe_object(avatar))
|
||||||
.set_image(apb::Node::link(banner))
|
.set_image(apb::Node::maybe_object(banner))
|
||||||
.set_published(Some(chrono::Utc::now()))
|
.set_published(Some(chrono::Utc::now()))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue