feat: add discoverable to actors
idk if it makes a difference? ap doesnt mention it but everyone has it
This commit is contained in:
parent
b27c2cf31a
commit
1d97b8d3f5
2 changed files with 22 additions and 0 deletions
|
@ -100,6 +100,12 @@ macro_rules! getter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
($name:ident -> bool) => {
|
||||||
|
fn $name(&self) -> Option<bool> {
|
||||||
|
self.get(stringify!($name))?.as_bool()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
($name:ident -> &str) => {
|
($name:ident -> &str) => {
|
||||||
fn $name(&self) -> Option<&str> {
|
fn $name(&self) -> Option<&str> {
|
||||||
self.get(stringify!($name))?.as_str()
|
self.get(stringify!($name))?.as_str()
|
||||||
|
@ -185,6 +191,17 @@ macro_rules! getter {
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! setter {
|
macro_rules! setter {
|
||||||
|
($name:ident -> bool) => {
|
||||||
|
paste::item! {
|
||||||
|
fn [< set_$name >](mut self, val: Option<bool>) -> Self {
|
||||||
|
$crate::activitystream::macros::set_maybe_value(
|
||||||
|
&mut self, stringify!($name), val.map(|x| serde_json::Value::Bool(x))
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
($name:ident -> &str) => {
|
($name:ident -> &str) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
fn [< set_$name >](mut self, val: Option<&str>) -> Self {
|
fn [< set_$name >](mut self, val: Option<&str>) -> Self {
|
||||||
|
|
|
@ -24,6 +24,8 @@ pub trait Actor : super::Object {
|
||||||
fn streams(&self) -> Node<impl Collection> { Node::empty() }
|
fn streams(&self) -> Node<impl Collection> { Node::empty() }
|
||||||
fn endpoints(&self) -> Option<serde_json::Map<String, String>> { None }
|
fn endpoints(&self) -> Option<serde_json::Map<String, String>> { None }
|
||||||
fn public_key(&self) -> Node<impl PublicKey> { Node::empty() }
|
fn public_key(&self) -> Node<impl PublicKey> { Node::empty() }
|
||||||
|
// idk about this? everyone has it but AP doesn't mention it
|
||||||
|
fn discoverable(&self) -> Option<bool> { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ActorMut : super::ObjectMut {
|
pub trait ActorMut : super::ObjectMut {
|
||||||
|
@ -37,6 +39,7 @@ pub trait ActorMut : super::ObjectMut {
|
||||||
fn set_streams(self, val: Node<impl Collection>) -> Self;
|
fn set_streams(self, val: Node<impl Collection>) -> Self;
|
||||||
fn set_endpoints(self, val: Option<serde_json::Map<String, String>>) -> Self;
|
fn set_endpoints(self, val: Option<serde_json::Map<String, String>>) -> Self;
|
||||||
fn set_public_key(self, val: Node<impl PublicKey>) -> Self;
|
fn set_public_key(self, val: Node<impl PublicKey>) -> Self;
|
||||||
|
fn set_discoverable(self, val: Option<bool>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Actor for serde_json::Value {
|
impl Actor for serde_json::Value {
|
||||||
|
@ -49,6 +52,7 @@ impl Actor for serde_json::Value {
|
||||||
getter! { liked -> node impl Collection }
|
getter! { liked -> node impl Collection }
|
||||||
getter! { streams -> node impl Collection }
|
getter! { streams -> node impl Collection }
|
||||||
getter! { public_key::publicKey -> node impl PublicKey }
|
getter! { public_key::publicKey -> node impl PublicKey }
|
||||||
|
getter! { discoverable -> bool }
|
||||||
|
|
||||||
fn endpoints(&self) -> Option<serde_json::Map<String, String>> {
|
fn endpoints(&self) -> Option<serde_json::Map<String, String>> {
|
||||||
todo!()
|
todo!()
|
||||||
|
@ -65,6 +69,7 @@ impl ActorMut for serde_json::Value {
|
||||||
setter! { liked -> node impl Collection }
|
setter! { liked -> node impl Collection }
|
||||||
setter! { streams -> node impl Collection }
|
setter! { streams -> node impl Collection }
|
||||||
setter! { public_key::publicKey -> node impl PublicKey }
|
setter! { public_key::publicKey -> node impl PublicKey }
|
||||||
|
setter! { discoverable -> bool }
|
||||||
|
|
||||||
fn set_endpoints(self, _val: Option<serde_json::Map<String, String>>) -> Self {
|
fn set_endpoints(self, _val: Option<serde_json::Map<String, String>>) -> Self {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
Loading…
Reference in a new issue