2 activities::generate_activity_id,
3 activity_queue::send_activity_single_dest,
4 extensions::context::lemmy_context,
10 kind::{DeleteType, UndoType},
14 base::{BaseExt, ExtendsExt},
17 use lemmy_api_common::blocking;
18 use lemmy_db_queries::Crud;
19 use lemmy_db_schema::source::{person::Person, private_message::PrivateMessage};
20 use lemmy_utils::LemmyError;
21 use lemmy_websocket::LemmyContext;
23 #[async_trait::async_trait(?Send)]
24 impl ApubObjectType for PrivateMessage {
25 async fn send_delete(&self, creator: &Person, context: &LemmyContext) -> Result<(), LemmyError> {
26 let recipient_id = self.recipient_id;
28 blocking(context.pool(), move |conn| Person::read(conn, recipient_id)).await??;
30 let mut delete = Delete::new(
31 creator.actor_id.to_owned().into_inner(),
32 self.ap_id.to_owned().into_inner(),
35 .set_many_contexts(lemmy_context())
36 .set_id(generate_activity_id(DeleteType::Delete)?)
37 .set_to(recipient.actor_id());
39 send_activity_single_dest(delete, creator, recipient.inbox_url.into(), context).await?;
43 async fn send_undo_delete(
46 context: &LemmyContext,
47 ) -> Result<(), LemmyError> {
48 let recipient_id = self.recipient_id;
50 blocking(context.pool(), move |conn| Person::read(conn, recipient_id)).await??;
52 let mut delete = Delete::new(
53 creator.actor_id.to_owned().into_inner(),
54 self.ap_id.to_owned().into_inner(),
57 .set_many_contexts(lemmy_context())
58 .set_id(generate_activity_id(DeleteType::Delete)?)
59 .set_to(recipient.actor_id());
61 // Undo that fake activity
62 let mut undo = Undo::new(
63 creator.actor_id.to_owned().into_inner(),
64 delete.into_any_base()?,
67 .set_many_contexts(lemmy_context())
68 .set_id(generate_activity_id(UndoType::Undo)?)
69 .set_to(recipient.actor_id());
71 send_activity_single_dest(undo, creator, recipient.inbox_url.into(), context).await?;
75 async fn send_remove(&self, _mod_: &Person, _context: &LemmyContext) -> Result<(), LemmyError> {
79 async fn send_undo_remove(
82 _context: &LemmyContext,
83 ) -> Result<(), LemmyError> {