Implement Comment::create_activity07()
This commit is contained in:
parent
1c1dbd481a
commit
88eb61c320
@ -17,7 +17,8 @@ use activitypub::{
|
|||||||
object::{Note, Tombstone},
|
object::{Note, Tombstone},
|
||||||
};
|
};
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
iri_string::types::IriString, object::Note as Note07, prelude::*, time::OffsetDateTime,
|
activity::Create as Create07, base::Base, iri_string::types::IriString, object::Note as Note07,
|
||||||
|
prelude::*, time::OffsetDateTime,
|
||||||
};
|
};
|
||||||
use chrono::{self, NaiveDateTime, TimeZone, Utc};
|
use chrono::{self, NaiveDateTime, TimeZone, Utc};
|
||||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||||
@ -200,6 +201,29 @@ impl Comment {
|
|||||||
Ok(act)
|
Ok(act)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_activity07(&self, conn: &DbConn) -> Result<Create07> {
|
||||||
|
let author = User::get(conn, self.author_id)?;
|
||||||
|
|
||||||
|
let note = self.to_activity07(conn)?;
|
||||||
|
let to = note.to().ok_or(Error::MissingApProperty)?.clone();
|
||||||
|
let cc = note.cc().ok_or(Error::MissingApProperty)?.clone();
|
||||||
|
|
||||||
|
let mut act = Create07::new(
|
||||||
|
author.into_id().parse::<IriString>()?,
|
||||||
|
Base::retract(note)?.into_generic()?,
|
||||||
|
);
|
||||||
|
act.set_id(
|
||||||
|
format!(
|
||||||
|
"{}/activity",
|
||||||
|
self.ap_url.clone().ok_or(Error::MissingApProperty)?,
|
||||||
|
)
|
||||||
|
.parse::<IriString>()?,
|
||||||
|
);
|
||||||
|
act.set_many_tos(to);
|
||||||
|
act.set_many_ccs(cc);
|
||||||
|
Ok(act)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn notify(&self, conn: &Connection) -> Result<()> {
|
pub fn notify(&self, conn: &Connection) -> Result<()> {
|
||||||
for author in self.get_post(conn)?.get_authors(conn)? {
|
for author in self.get_post(conn)?.get_authors(conn)? {
|
||||||
if Mention::list_for_comment(conn, self.id)?
|
if Mention::list_for_comment(conn, self.id)?
|
||||||
|
Loading…
Reference in New Issue
Block a user