1 use crate::objects::person::ApubPerson;
2 use lemmy_api_common::blocking;
3 use lemmy_apub_lib::object_id::ObjectId;
6 source::{comment::Comment, post::Post},
9 use lemmy_utils::{utils::scrape_text_for_mentions, LemmyError};
10 use lemmy_websocket::{send::send_local_notifs, LemmyContext};
12 pub mod create_or_update;
14 async fn get_notif_recipients(
15 actor: &ObjectId<ApubPerson>,
18 context: &LemmyContext,
19 request_counter: &mut i32,
20 ) -> Result<Vec<LocalUserId>, LemmyError> {
21 let post_id = comment.post_id;
22 let post = blocking(context.pool(), move |conn| Post::read(conn, post_id)).await??;
23 let actor = actor.dereference(context, request_counter).await?;
26 // Although mentions could be gotten from the post tags (they are included there), or the ccs,
27 // Its much easier to scrape them from the comment body, since the API has to do that
29 // TODO: for compatibility with other projects, it would be much better to read this from cc or tags
30 let mentions = scrape_text_for_mentions(&comment.content);
31 send_local_notifs(mentions, comment, &*actor, &post, do_send_email, context).await