diff --git a/apb/Cargo.toml b/apb/Cargo.toml index 374d8d6..9449d0d 100644 --- a/apb/Cargo.toml +++ b/apb/Cargo.toml @@ -28,6 +28,7 @@ default = ["activitypub-miscellaneous-terms"] # extensions activitypub-miscellaneous-terms = [] # https://swicg.github.io/miscellany/ activitypub-counters = [] # https://ns.alemi.dev/as/counters/# +activitypub-fe = [] # https://ns.alemi.dev/as/fe/# # 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 214bd5b..df01590 100644 --- a/apb/src/types/object/actor.rs +++ b/apb/src/types/object/actor.rs @@ -26,7 +26,6 @@ pub trait Actor : Object { #[cfg(feature = "activitypub-miscellaneous-terms")] fn moved_to(&self) -> Node { Node::Empty } - #[cfg(feature = "activitypub-miscellaneous-terms")] fn manually_approves_followers(&self) -> Option { None } @@ -35,6 +34,13 @@ pub trait Actor : Object { #[cfg(feature = "activitypub-fe")] fn followed_by_me(&self) -> Option { None } + #[cfg(feature = "activitypub-counters")] + fn followers_count(&self) -> Option { None } + #[cfg(feature = "activitypub-counters")] + fn following_count(&self) -> Option { None } + #[cfg(feature = "activitypub-counters")] + fn statuses_count(&self) -> Option { None } + // idk about this? everyone has it but AP doesn't mention it fn discoverable(&self) -> Option { None } } @@ -63,6 +69,13 @@ pub trait ActorMut : ObjectMut { #[cfg(feature = "activitypub-fe")] fn set_followed_by_me(self, val: Option) -> Self; + #[cfg(feature = "activitypub-counters")] + fn set_followers_count(self, val: Option) -> Self; + #[cfg(feature = "activitypub-counters")] + fn set_following_count(self, val: Option) -> Self; + #[cfg(feature = "activitypub-counters")] + fn set_statuses_count(self, val: Option) -> Self; + fn set_discoverable(self, val: Option) -> Self; } @@ -90,6 +103,13 @@ impl Actor for serde_json::Value { #[cfg(feature = "activitypub-fe")] crate::getter! { followed_by_me::followedByMe -> bool } + #[cfg(feature = "activitypub-counters")] + crate::getter! { following_count::followingCount -> u64 } + #[cfg(feature = "activitypub-counters")] + crate::getter! { followers_count::followersCount -> u64 } + #[cfg(feature = "activitypub-counters")] + crate::getter! { statuses_count::statusesCount -> u64 } + crate::getter! { discoverable -> bool } fn endpoints(&self) -> Node<::Object> { @@ -121,6 +141,14 @@ impl ActorMut for serde_json::Value { crate::setter! { following_me::followingMe -> bool } #[cfg(feature = "activitypub-fe")] crate::setter! { followed_by_me::followedByMe -> bool } + + #[cfg(feature = "activitypub-counters")] + crate::setter! { following_count::followingCount -> u64 } + #[cfg(feature = "activitypub-counters")] + crate::setter! { followers_count::followersCount -> u64 } + #[cfg(feature = "activitypub-counters")] + crate::setter! { statuses_count::statusesCount -> u64 } + 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