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 {
28 _context: &LemmyContext,
29 ) -> Result<(), LemmyError> {
36 _context: &LemmyContext,
37 ) -> Result<(), LemmyError> {
41 async fn send_delete(&self, creator: &Person, context: &LemmyContext) -> Result<(), LemmyError> {
42 let recipient_id = self.recipient_id;
44 blocking(context.pool(), move |conn| Person::read(conn, recipient_id)).await??;
46 let mut delete = Delete::new(
47 creator.actor_id.to_owned().into_inner(),
48 self.ap_id.to_owned().into_inner(),
51 .set_many_contexts(lemmy_context())
52 .set_id(generate_activity_id(DeleteType::Delete)?)
53 .set_to(recipient.actor_id());
55 send_activity_single_dest(delete, creator, recipient.inbox_url.into(), context).await?;
59 async fn send_undo_delete(
62 context: &LemmyContext,
63 ) -> Result<(), LemmyError> {
64 let recipient_id = self.recipient_id;
66 blocking(context.pool(), move |conn| Person::read(conn, recipient_id)).await??;
68 let mut delete = Delete::new(
69 creator.actor_id.to_owned().into_inner(),
70 self.ap_id.to_owned().into_inner(),
73 .set_many_contexts(lemmy_context())
74 .set_id(generate_activity_id(DeleteType::Delete)?)
75 .set_to(recipient.actor_id());
77 // Undo that fake activity
78 let mut undo = Undo::new(
79 creator.actor_id.to_owned().into_inner(),
80 delete.into_any_base()?,
83 .set_many_contexts(lemmy_context())
84 .set_id(generate_activity_id(UndoType::Undo)?)
85 .set_to(recipient.actor_id());
87 send_activity_single_dest(undo, creator, recipient.inbox_url.into(), context).await?;
91 async fn send_remove(&self, _mod_: &Person, _context: &LemmyContext) -> Result<(), LemmyError> {
95 async fn send_undo_remove(
98 _context: &LemmyContext,
99 ) -> Result<(), LemmyError> {