Compare commits

..

No commits in common. "3d504e5059a3e6f098f748ef261e2cf3a7ceefa8" and "9abf1b65ab792d4b99596a93051c2b326030dd86" have entirely different histories.

4 changed files with 14 additions and 44 deletions

View file

@ -18,7 +18,6 @@ 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
@ -30,7 +29,6 @@ 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
@ -58,7 +56,6 @@ 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 }
@ -83,7 +80,6 @@ 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 }

View file

@ -92,8 +92,7 @@ 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
// TODO technically this is an object? but spec says that it works my reference, idk fn tag(&self) -> Node<Self::Object> { Node::Empty }
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

View file

@ -57,13 +57,9 @@ impl Entity {
} }
pub async fn nodeinfo(domain: &str) -> reqwest::Result<NodeInfoOwned> { pub async fn nodeinfo(domain: &str) -> reqwest::Result<NodeInfoOwned> {
match reqwest::get(format!("https://{domain}/nodeinfo/2.0.json")).await { reqwest::get(format!("https://{domain}/nodeinfo/2.0.json"))
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
}
} }
} }

View file

@ -1,4 +1,4 @@
use apb::{ActivityMut, DocumentMut, Object, ObjectMut}; use apb::{ActivityMut, Object, ObjectMut};
use leptos::*; use leptos::*;
use crate::{prelude::*, DEFAULT_COLOR}; use crate::{prelude::*, DEFAULT_COLOR};
@ -131,31 +131,10 @@ 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() let display_name = display_name_ref.get().map(|x| x.value()).unwrap_or("".into());
.map(|x| x.value()) let avatar = avatar_url_ref.get().map(|x| x.value()).unwrap_or("".into());
.filter(|x| !x.is_empty()); let banner = banner_url_ref.get().map(|x| x.value()).unwrap_or("".into());
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 {
@ -168,10 +147,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(display_name.as_deref()) .set_name(Some(&display_name))
.set_summary(summary.as_deref()) .set_summary(Some(&summary))
.set_icon(apb::Node::maybe_object(avatar)) .set_icon(apb::Node::link(avatar))
.set_image(apb::Node::maybe_object(banner)) .set_image(apb::Node::link(banner))
.set_published(Some(chrono::Utc::now())) .set_published(Some(chrono::Utc::now()))
)); ));