From 2ac0ca8a38c18ef14f6ac0431f4ef0e831d8f5fc Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 20 May 2024 08:58:38 +0200 Subject: [PATCH] feat(apb): quote url --- apb/src/types/object/mod.rs | 8 ++++++++ src/routes/activitypub/jsonld.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/apb/src/types/object/mod.rs b/apb/src/types/object/mod.rs index 9f829c1..d439c5d 100644 --- a/apb/src/types/object/mod.rs +++ b/apb/src/types/object/mod.rs @@ -72,6 +72,8 @@ pub trait Object : Base { #[cfg(feature = "activitypub-miscellaneous-terms")] fn sensitive(&self) -> Option { None } + #[cfg(feature = "activitypub-miscellaneous-terms")] + fn quote_url(&self) -> Node { Node::Empty } #[cfg(feature = "activitypub-fe")] fn liked_by_me(&self) -> Option { None } @@ -121,6 +123,8 @@ pub trait ObjectMut : BaseMut { #[cfg(feature = "activitypub-miscellaneous-terms")] fn set_sensitive(self, val: Option) -> Self; + #[cfg(feature = "activitypub-miscellaneous-terms")] + fn set_quote_url(self, val: Node) -> Self; #[cfg(feature = "activitypub-fe")] fn set_liked_by_me(self, val: Option) -> Self; @@ -166,6 +170,8 @@ impl Object for serde_json::Value { #[cfg(feature = "activitypub-miscellaneous-terms")] crate::getter! { sensitive -> bool } + #[cfg(feature = "activitypub-miscellaneous-terms")] + crate::getter! { quote_url::quoteUrl -> node ::Object } #[cfg(feature = "activitypub-fe")] crate::getter! { liked_by_me::likedByMe -> bool } @@ -250,6 +256,8 @@ impl ObjectMut for serde_json::Value { #[cfg(feature = "activitypub-miscellaneous-terms")] crate::setter! { sensitive -> bool } + #[cfg(feature = "activitypub-miscellaneous-terms")] + crate::setter! { quote_url::quoteUrl -> node ::Object } #[cfg(feature = "activitypub-fe")] crate::setter! { liked_by_me::likedByMe -> bool } diff --git a/src/routes/activitypub/jsonld.rs b/src/routes/activitypub/jsonld.rs index 0c2188e..d9e2b54 100644 --- a/src/routes/activitypub/jsonld.rs +++ b/src/routes/activitypub/jsonld.rs @@ -19,6 +19,7 @@ impl LD for serde_json::Value { if let Some(obj) = self.as_object_mut() { let mut ctx = serde_json::Map::new(); ctx.insert("sensitive".to_string(), serde_json::Value::String("as:sensitive".into())); + ctx.insert("quoteUrl".to_string(), serde_json::Value::String("as:quoteUrl".into())); match o_type { Some(apb::ObjectType::Actor(_)) => { ctx.insert("counters".to_string(), serde_json::Value::String("https://ns.alemi.dev/as/counters/#".into()));