mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-23 12:01:02 +00:00
Implement Comment::create_activity07()
This commit is contained in:
parent
1c1dbd481a
commit
88eb61c320
1 changed files with 25 additions and 1 deletions
|
@ -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 a new issue