feat(apb): added my apb extension for frontends
very much ad-hoc but at least i made the ns page so it should be kind of ok to use i think? if others want to use upub frontend and have all its features working, this extension will be necessary, rather than some custom whole api
This commit is contained in:
parent
a615b5d4e8
commit
05bce0c486
3 changed files with 34 additions and 0 deletions
|
@ -27,6 +27,7 @@ reqwest = { version = "0.12", features = ["json"], optional = true }
|
||||||
default = ["activitypub-miscellaneous-terms"]
|
default = ["activitypub-miscellaneous-terms"]
|
||||||
# extensions
|
# extensions
|
||||||
activitypub-miscellaneous-terms = []
|
activitypub-miscellaneous-terms = []
|
||||||
|
activitypub-counters = [] # https://ns.alemi.dev/as/counters/#
|
||||||
# builtin utils
|
# builtin utils
|
||||||
orm = ["dep:sea-orm"]
|
orm = ["dep:sea-orm"]
|
||||||
fetch = ["dep:reqwest"]
|
fetch = ["dep:reqwest"]
|
||||||
|
|
|
@ -30,6 +30,11 @@ pub trait Actor : Object {
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
fn manually_approves_followers(&self) -> Option<bool> { None }
|
fn manually_approves_followers(&self) -> Option<bool> { None }
|
||||||
|
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
fn following_me(&self) -> Option<bool> { None }
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
fn followed_by_me(&self) -> Option<bool> { None }
|
||||||
|
|
||||||
// idk about this? everyone has it but AP doesn't mention it
|
// idk about this? everyone has it but AP doesn't mention it
|
||||||
fn discoverable(&self) -> Option<bool> { None }
|
fn discoverable(&self) -> Option<bool> { None }
|
||||||
}
|
}
|
||||||
|
@ -47,6 +52,11 @@ pub trait ActorMut : ObjectMut {
|
||||||
fn set_streams(self, val: Node<Self::Collection>) -> Self;
|
fn set_streams(self, val: Node<Self::Collection>) -> Self;
|
||||||
fn set_endpoints(self, val: Node<Self::Object>) -> Self; // TODO it's more complex than this!
|
fn set_endpoints(self, val: Node<Self::Object>) -> Self; // TODO it's more complex than this!
|
||||||
fn set_public_key(self, val: Node<Self::PublicKey>) -> Self;
|
fn set_public_key(self, val: Node<Self::PublicKey>) -> Self;
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
fn set_following_me(self, val: Option<bool>) -> Self;
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
fn set_followed_by_me(self, val: Option<bool>) -> Self;
|
||||||
|
|
||||||
fn set_discoverable(self, val: Option<bool>) -> Self;
|
fn set_discoverable(self, val: Option<bool>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +73,12 @@ impl Actor for serde_json::Value {
|
||||||
crate::getter! { liked -> node Self::Collection }
|
crate::getter! { liked -> node Self::Collection }
|
||||||
crate::getter! { streams -> node Self::Collection }
|
crate::getter! { streams -> node Self::Collection }
|
||||||
crate::getter! { public_key::publicKey -> node Self::PublicKey }
|
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 }
|
crate::getter! { discoverable -> bool }
|
||||||
|
|
||||||
fn endpoints(&self) -> Node<<Self as Object>::Object> {
|
fn endpoints(&self) -> Node<<Self as Object>::Object> {
|
||||||
|
@ -85,6 +101,11 @@ impl ActorMut for serde_json::Value {
|
||||||
crate::setter! { public_key::publicKey -> node Self::PublicKey }
|
crate::setter! { public_key::publicKey -> node Self::PublicKey }
|
||||||
crate::setter! { discoverable -> bool }
|
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<<Self as Object>::Object>) -> Self {
|
fn set_endpoints(mut self, _val: Node<<Self as Object>::Object>) -> Self {
|
||||||
self.as_object_mut().unwrap().insert("endpoints".to_string(), serde_json::Value::Object(serde_json::Map::default()));
|
self.as_object_mut().unwrap().insert("endpoints".to_string(), serde_json::Value::Object(serde_json::Map::default()));
|
||||||
self
|
self
|
||||||
|
|
|
@ -73,6 +73,9 @@ pub trait Object : Base {
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
fn sensitive(&self) -> Option<bool> { None }
|
fn sensitive(&self) -> Option<bool> { None }
|
||||||
|
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
fn liked_by_me(&self) -> Option<bool> { None }
|
||||||
|
|
||||||
fn as_activity(&self) -> Option<&Self::Activity> { None }
|
fn as_activity(&self) -> Option<&Self::Activity> { None }
|
||||||
fn as_actor(&self) -> Option<&Self::Actor> { None }
|
fn as_actor(&self) -> Option<&Self::Actor> { None }
|
||||||
fn as_collection(&self) -> Option<&Self::Collection> { None }
|
fn as_collection(&self) -> Option<&Self::Collection> { None }
|
||||||
|
@ -118,6 +121,9 @@ pub trait ObjectMut : BaseMut {
|
||||||
|
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
fn set_sensitive(self, val: Option<bool>) -> Self;
|
fn set_sensitive(self, val: Option<bool>) -> Self;
|
||||||
|
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
fn set_liked_by_me(self, val: Option<bool>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstructured")]
|
#[cfg(feature = "unstructured")]
|
||||||
|
@ -161,6 +167,9 @@ impl Object for serde_json::Value {
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
crate::getter! { sensitive -> bool }
|
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!!
|
// TODO Mastodon doesn't use a "context" field on the object but makes up a new one!!
|
||||||
fn context(&self) -> Node<<Self as Object>::Object> {
|
fn context(&self) -> Node<<Self as Object>::Object> {
|
||||||
match self.get("context") {
|
match self.get("context") {
|
||||||
|
@ -241,4 +250,7 @@ impl ObjectMut for serde_json::Value {
|
||||||
|
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
crate::setter! { sensitive -> bool }
|
crate::setter! { sensitive -> bool }
|
||||||
|
|
||||||
|
#[cfg(feature = "activitypub-fe")]
|
||||||
|
crate::setter! { liked_by_me::likedByMe -> bool }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue