forked from alemi/upub
feat(apb): mentioning method for jut .to() and .bto()
This commit is contained in:
parent
e6b9120bbf
commit
827fb287db
3 changed files with 43 additions and 6 deletions
|
@ -4,7 +4,7 @@ pub const PUBLIC : &str = "https://www.w3.org/ns/activitystreams#Public";
|
||||||
|
|
||||||
pub trait Addressed {
|
pub trait Addressed {
|
||||||
fn addressed(&self) -> Vec<String>; // TODO rename this? remate others? idk
|
fn addressed(&self) -> Vec<String>; // TODO rename this? remate others? idk
|
||||||
// fn primary_targets(&self) -> Vec<String>;
|
fn mentioning(&self) -> Vec<String>;
|
||||||
// fn secondary_targets(&self) -> Vec<String>;
|
// fn secondary_targets(&self) -> Vec<String>;
|
||||||
// fn public_targets(&self) -> Vec<String>;
|
// fn public_targets(&self) -> Vec<String>;
|
||||||
// fn private_targets(&self) -> Vec<String>;
|
// fn private_targets(&self) -> Vec<String>;
|
||||||
|
@ -19,11 +19,11 @@ impl<T: Object> Addressed for T {
|
||||||
to
|
to
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn primary_targets(&self) -> Vec<String> {
|
fn mentioning(&self) -> Vec<String> {
|
||||||
// let mut to : Vec<String> = self.to().ids();
|
let mut to : Vec<String> = self.to().all_ids();
|
||||||
// to.append(&mut self.bto().ids());
|
to.append(&mut self.bto().all_ids());
|
||||||
// to
|
to
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn secondary_targets(&self) -> Vec<String> {
|
// fn secondary_targets(&self) -> Vec<String> {
|
||||||
// let mut to : Vec<String> = self.cc().ids();
|
// let mut to : Vec<String> = self.cc().ids();
|
||||||
|
@ -73,4 +73,29 @@ mod test {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "unstructured")]
|
||||||
|
fn primary_targets_only_finds_to_and_bto() {
|
||||||
|
let obj = serde_json::json!({
|
||||||
|
"id": "http://localhost:8080/obj/1",
|
||||||
|
"type": "Note",
|
||||||
|
"content": "hello world!",
|
||||||
|
"published": "2024-06-04T17:09:20+00:00",
|
||||||
|
"to": ["http://localhost:8080/usr/root/followers"],
|
||||||
|
"bto": ["https://localhost:8080/usr/secret"],
|
||||||
|
"cc": [crate::target::PUBLIC],
|
||||||
|
"bcc": [],
|
||||||
|
});
|
||||||
|
|
||||||
|
let addressed = obj.mentioning();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
addressed,
|
||||||
|
vec![
|
||||||
|
"http://localhost:8080/usr/root/followers".to_string(),
|
||||||
|
"https://localhost:8080/usr/secret".to_string(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,4 +103,10 @@ impl apb::target::Addressed for Model {
|
||||||
to.append(&mut self.bcc.0.clone());
|
to.append(&mut self.bcc.0.clone());
|
||||||
to
|
to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mentioning(&self) -> Vec<String> {
|
||||||
|
let mut to = self.to.0.clone();
|
||||||
|
to.append(&mut self.bto.0.clone());
|
||||||
|
to
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,4 +189,10 @@ impl apb::target::Addressed for Model {
|
||||||
to.append(&mut self.bcc.0.clone());
|
to.append(&mut self.bcc.0.clone());
|
||||||
to
|
to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mentioning(&self) -> Vec<String> {
|
||||||
|
let mut to = self.to.0.clone();
|
||||||
|
to.append(&mut self.bto.0.clone());
|
||||||
|
to
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue