Implement Post::create_activity07()
This commit is contained in:
parent
c37ff54857
commit
680d321a2e
@ -10,7 +10,8 @@ use activitypub::{
|
||||
CustomObject,
|
||||
};
|
||||
use activitystreams::{
|
||||
base::AnyBase,
|
||||
activity::Create as Create07,
|
||||
base::{AnyBase, Base},
|
||||
iri_string::types::IriString,
|
||||
object::{ApObject, Article as Article07, Image as Image07},
|
||||
prelude::*,
|
||||
@ -506,6 +507,20 @@ impl Post {
|
||||
Ok(act)
|
||||
}
|
||||
|
||||
pub fn create_activity07(&self, conn: &Connection) -> Result<Create07> {
|
||||
let article = self.to_activity07(conn)?;
|
||||
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
|
||||
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
|
||||
let mut act = Create07::new(
|
||||
self.get_authors(conn)?[0].ap_url.parse::<IriString>()?,
|
||||
Base::retract(article)?.into_generic()?,
|
||||
);
|
||||
act.set_id(format!("{}/activity", self.ap_url).parse::<IriString>()?);
|
||||
act.set_many_tos(to);
|
||||
act.set_many_ccs(cc);
|
||||
Ok(act)
|
||||
}
|
||||
|
||||
pub fn update_activity(&self, conn: &Connection) -> Result<Update> {
|
||||
let article = self.to_activity(conn)?;
|
||||
let mut act = Update::default();
|
||||
|
Loading…
Reference in New Issue
Block a user