diff --git a/apb/Cargo.toml b/apb/Cargo.toml index b80300c0..6775ef27 100644 --- a/apb/Cargo.toml +++ b/apb/Cargo.toml @@ -27,6 +27,7 @@ reqwest = { version = "0.12", features = ["json"], optional = true } default = ["activitypub-miscellaneous-terms"] # extensions activitypub-miscellaneous-terms = [] +activitypub-counters = [] # https://ns.alemi.dev/as/counters/# # builtin utils orm = ["dep:sea-orm"] fetch = ["dep:reqwest"] diff --git a/apb/src/types/object/actor.rs b/apb/src/types/object/actor.rs index 93895b7d..66056330 100644 --- a/apb/src/types/object/actor.rs +++ b/apb/src/types/object/actor.rs @@ -30,6 +30,11 @@ pub trait Actor : Object { #[cfg(feature = "activitypub-miscellaneous-terms")] fn manually_approves_followers(&self) -> Option { None } + #[cfg(feature = "activitypub-fe")] + fn following_me(&self) -> Option { None } + #[cfg(feature = "activitypub-fe")] + fn followed_by_me(&self) -> Option { None } + // idk about this? everyone has it but AP doesn't mention it fn discoverable(&self) -> Option { None } } @@ -47,6 +52,11 @@ pub trait ActorMut : ObjectMut { fn set_streams(self, val: Node) -> Self; fn set_endpoints(self, val: Node) -> Self; // TODO it's more complex than this! fn set_public_key(self, val: Node) -> Self; + #[cfg(feature = "activitypub-fe")] + fn set_following_me(self, val: Option) -> Self; + #[cfg(feature = "activitypub-fe")] + fn set_followed_by_me(self, val: Option) -> Self; + fn set_discoverable(self, val: Option) -> Self; } @@ -63,6 +73,12 @@ impl Actor for serde_json::Value { crate::getter! { liked -> node Self::Collection } crate::getter! { streams -> node Self::Collection } crate::getter! { public_key::publicKey -> node Self::PublicKey } + + #[cfg(feature = "activitypub-fe")] + crate::getter! { following_me::followingMe -> bool } + #[cfg(feature = "activitypub-fe")] + crate::getter! { followed_by_me::followedByMe -> bool } + crate::getter! { discoverable -> bool } fn endpoints(&self) -> Node<::Object> { @@ -85,6 +101,11 @@ impl ActorMut for serde_json::Value { crate::setter! { public_key::publicKey -> node Self::PublicKey } crate::setter! { discoverable -> bool } + + #[cfg(feature = "activitypub-fe")] + crate::setter! { following_me::followingMe -> bool } + #[cfg(feature = "activitypub-fe")] + crate::setter! { followed_by_me::followedByMe -> bool } fn set_endpoints(mut self, _val: Node<::Object>) -> Self { self.as_object_mut().unwrap().insert("endpoints".to_string(), serde_json::Value::Object(serde_json::Map::default())); self diff --git a/apb/src/types/object/mod.rs b/apb/src/types/object/mod.rs index 67b4fbf8..a6adbe44 100644 --- a/apb/src/types/object/mod.rs +++ b/apb/src/types/object/mod.rs @@ -73,6 +73,9 @@ pub trait Object : Base { #[cfg(feature = "activitypub-miscellaneous-terms")] fn sensitive(&self) -> Option { None } + #[cfg(feature = "activitypub-fe")] + fn liked_by_me(&self) -> Option { None } + fn as_activity(&self) -> Option<&Self::Activity> { None } fn as_actor(&self) -> Option<&Self::Actor> { None } fn as_collection(&self) -> Option<&Self::Collection> { None } @@ -118,6 +121,9 @@ pub trait ObjectMut : BaseMut { #[cfg(feature = "activitypub-miscellaneous-terms")] fn set_sensitive(self, val: Option) -> Self; + + #[cfg(feature = "activitypub-fe")] + fn set_liked_by_me(self, val: Option) -> Self; } #[cfg(feature = "unstructured")] @@ -161,6 +167,9 @@ impl Object for serde_json::Value { #[cfg(feature = "activitypub-miscellaneous-terms")] crate::getter! { sensitive -> bool } + #[cfg(feature = "activitypub-fe")] + crate::getter! { liked_by_me::likedByMe -> bool } + // TODO Mastodon doesn't use a "context" field on the object but makes up a new one!! fn context(&self) -> Node<::Object> { match self.get("context") { @@ -241,4 +250,7 @@ impl ObjectMut for serde_json::Value { #[cfg(feature = "activitypub-miscellaneous-terms")] crate::setter! { sensitive -> bool } + + #[cfg(feature = "activitypub-fe")] + crate::setter! { liked_by_me::likedByMe -> bool } }