feat(apb): ostatus conversation and toot discoverable
This commit is contained in:
parent
35796c6e93
commit
34c01dd858
3 changed files with 21 additions and 13 deletions
|
@ -29,6 +29,8 @@ default = ["activitypub-miscellaneous-terms", "send"]
|
||||||
activitypub-miscellaneous-terms = [] # https://swicg.github.io/miscellany/
|
activitypub-miscellaneous-terms = [] # https://swicg.github.io/miscellany/
|
||||||
activitypub-counters = [] # https://ns.alemi.dev/as/counters/#
|
activitypub-counters = [] # https://ns.alemi.dev/as/counters/#
|
||||||
activitypub-fe = [] # https://ns.alemi.dev/as/fe/#
|
activitypub-fe = [] # https://ns.alemi.dev/as/fe/#
|
||||||
|
ostatus = [] # https://ostatus.org# , but it redirects and 403??? just need this for conversation
|
||||||
|
toot = [] # http://joinmastodon.org/ns# , mastodon is weird tho??
|
||||||
litepub = [] # incomplete, https://litepub.social/
|
litepub = [] # incomplete, https://litepub.social/
|
||||||
# builtin utils
|
# builtin utils
|
||||||
send = []
|
send = []
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub trait Actor : Object {
|
||||||
#[cfg(feature = "activitypub-counters")]
|
#[cfg(feature = "activitypub-counters")]
|
||||||
fn statuses_count(&self) -> Option<u64> { None }
|
fn statuses_count(&self) -> Option<u64> { None }
|
||||||
|
|
||||||
// idk about this? everyone has it but AP doesn't mention it
|
#[cfg(feature = "toot")]
|
||||||
fn discoverable(&self) -> Option<bool> { None }
|
fn discoverable(&self) -> Option<bool> { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ pub trait ActorMut : ObjectMut {
|
||||||
#[cfg(feature = "activitypub-counters")]
|
#[cfg(feature = "activitypub-counters")]
|
||||||
fn set_statuses_count(self, val: Option<u64>) -> Self;
|
fn set_statuses_count(self, val: Option<u64>) -> Self;
|
||||||
|
|
||||||
|
#[cfg(feature = "toot")]
|
||||||
fn set_discoverable(self, val: Option<bool>) -> Self;
|
fn set_discoverable(self, val: Option<bool>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ impl Actor for serde_json::Value {
|
||||||
#[cfg(feature = "activitypub-counters")]
|
#[cfg(feature = "activitypub-counters")]
|
||||||
crate::getter! { statuses_count::statusesCount -> u64 }
|
crate::getter! { statuses_count::statusesCount -> u64 }
|
||||||
|
|
||||||
|
#[cfg(feature = "toot")]
|
||||||
crate::getter! { discoverable -> bool }
|
crate::getter! { discoverable -> bool }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +174,6 @@ impl ActorMut for serde_json::Value {
|
||||||
crate::setter! { streams -> node Self::Collection }
|
crate::setter! { streams -> node Self::Collection }
|
||||||
crate::setter! { public_key::publicKey -> node Self::PublicKey }
|
crate::setter! { public_key::publicKey -> node Self::PublicKey }
|
||||||
crate::setter! { endpoints -> node Self::Endpoints }
|
crate::setter! { endpoints -> node Self::Endpoints }
|
||||||
crate::setter! { discoverable -> bool }
|
|
||||||
|
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
crate::setter! { moved_to::movedTo -> node Self::Actor }
|
crate::setter! { moved_to::movedTo -> node Self::Actor }
|
||||||
|
@ -190,6 +191,9 @@ impl ActorMut for serde_json::Value {
|
||||||
crate::setter! { followers_count::followersCount -> u64 }
|
crate::setter! { followers_count::followersCount -> u64 }
|
||||||
#[cfg(feature = "activitypub-counters")]
|
#[cfg(feature = "activitypub-counters")]
|
||||||
crate::setter! { statuses_count::statusesCount -> u64 }
|
crate::setter! { statuses_count::statusesCount -> u64 }
|
||||||
|
|
||||||
|
#[cfg(feature = "toot")]
|
||||||
|
crate::setter! { discoverable -> bool }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstructured")]
|
#[cfg(feature = "unstructured")]
|
||||||
|
|
|
@ -78,6 +78,9 @@ pub trait Object : Base {
|
||||||
#[cfg(feature = "activitypub-fe")]
|
#[cfg(feature = "activitypub-fe")]
|
||||||
fn liked_by_me(&self) -> Option<bool> { None }
|
fn liked_by_me(&self) -> Option<bool> { None }
|
||||||
|
|
||||||
|
#[cfg(feature = "ostatus")]
|
||||||
|
fn conversation(&self) -> Node<Self::Object> { Node::Empty }
|
||||||
|
|
||||||
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 }
|
||||||
|
@ -128,6 +131,9 @@ pub trait ObjectMut : BaseMut {
|
||||||
|
|
||||||
#[cfg(feature = "activitypub-fe")]
|
#[cfg(feature = "activitypub-fe")]
|
||||||
fn set_liked_by_me(self, val: Option<bool>) -> Self;
|
fn set_liked_by_me(self, val: Option<bool>) -> Self;
|
||||||
|
|
||||||
|
#[cfg(feature = "ostatus")]
|
||||||
|
fn set_conversation(self, val: Node<Self::Object>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstructured")]
|
#[cfg(feature = "unstructured")]
|
||||||
|
@ -144,6 +150,7 @@ impl Object for serde_json::Value {
|
||||||
crate::getter! { attributed_to::attributedTo -> node Self::Actor }
|
crate::getter! { attributed_to::attributedTo -> node Self::Actor }
|
||||||
crate::getter! { audience -> node Self::Actor }
|
crate::getter! { audience -> node Self::Actor }
|
||||||
crate::getter! { content -> &str }
|
crate::getter! { content -> &str }
|
||||||
|
crate::getter! { context -> node <Self as Object>::Object }
|
||||||
crate::getter! { name -> &str }
|
crate::getter! { name -> &str }
|
||||||
crate::getter! { end_time::endTime -> chrono::DateTime<chrono::Utc> }
|
crate::getter! { end_time::endTime -> chrono::DateTime<chrono::Utc> }
|
||||||
crate::getter! { generator -> node Self::Actor }
|
crate::getter! { generator -> node Self::Actor }
|
||||||
|
@ -176,16 +183,8 @@ impl Object for serde_json::Value {
|
||||||
#[cfg(feature = "activitypub-fe")]
|
#[cfg(feature = "activitypub-fe")]
|
||||||
crate::getter! { liked_by_me::likedByMe -> bool }
|
crate::getter! { liked_by_me::likedByMe -> bool }
|
||||||
|
|
||||||
// TODO Mastodon doesn't use a "context" field on the object but makes up a new one!!
|
#[cfg(feature = "ostatus")]
|
||||||
fn context(&self) -> Node<<Self as Object>::Object> {
|
crate::getter! { conversation -> node <Self as Object>::Object }
|
||||||
match self.get("context") {
|
|
||||||
Some(x) => Node::from(x.clone()),
|
|
||||||
None => match self.get("conversation") {
|
|
||||||
Some(x) => Node::from(x.clone()),
|
|
||||||
None => Node::Empty,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn as_activity(&self) -> Option<&Self::Activity> {
|
fn as_activity(&self) -> Option<&Self::Activity> {
|
||||||
match self.object_type() {
|
match self.object_type() {
|
||||||
|
@ -229,6 +228,7 @@ impl ObjectMut for serde_json::Value {
|
||||||
crate::setter! { attributed_to::attributedTo -> node Self::Actor }
|
crate::setter! { attributed_to::attributedTo -> node Self::Actor }
|
||||||
crate::setter! { audience -> node Self::Actor }
|
crate::setter! { audience -> node Self::Actor }
|
||||||
crate::setter! { content -> &str }
|
crate::setter! { content -> &str }
|
||||||
|
crate::setter! { context -> node <Self as Object>::Object }
|
||||||
crate::setter! { name -> &str }
|
crate::setter! { name -> &str }
|
||||||
crate::setter! { end_time::endTime -> chrono::DateTime<chrono::Utc> }
|
crate::setter! { end_time::endTime -> chrono::DateTime<chrono::Utc> }
|
||||||
crate::setter! { generator -> node Self::Actor }
|
crate::setter! { generator -> node Self::Actor }
|
||||||
|
@ -252,7 +252,6 @@ impl ObjectMut for serde_json::Value {
|
||||||
crate::setter! { media_type::mediaType -> &str }
|
crate::setter! { media_type::mediaType -> &str }
|
||||||
crate::setter! { duration -> &str }
|
crate::setter! { duration -> &str }
|
||||||
crate::setter! { url -> node Self::Link }
|
crate::setter! { url -> node Self::Link }
|
||||||
crate::setter! { context -> node <Self as Object>::Object }
|
|
||||||
|
|
||||||
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
#[cfg(feature = "activitypub-miscellaneous-terms")]
|
||||||
crate::setter! { sensitive -> bool }
|
crate::setter! { sensitive -> bool }
|
||||||
|
@ -261,4 +260,7 @@ impl ObjectMut for serde_json::Value {
|
||||||
|
|
||||||
#[cfg(feature = "activitypub-fe")]
|
#[cfg(feature = "activitypub-fe")]
|
||||||
crate::setter! { liked_by_me::likedByMe -> bool }
|
crate::setter! { liked_by_me::likedByMe -> bool }
|
||||||
|
|
||||||
|
#[cfg(feature = "ostatus")]
|
||||||
|
crate::setter! { conversation -> node <Self as Object>::Object }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue