1 use crate::fetcher::person::get_or_fetch_and_upsert_person;
2 use lemmy_api_common::{blocking, comment::CommentResponse, send_local_notifs};
3 use lemmy_db_queries::Crud;
5 source::{comment::Comment, post::Post},
9 use lemmy_db_views::comment_view::CommentView;
10 use lemmy_utils::{utils::scrape_text_for_mentions, LemmyError};
11 use lemmy_websocket::{messages::SendComment, LemmyContext};
17 async fn get_notif_recipients(
20 context: &LemmyContext,
21 request_counter: &mut i32,
22 ) -> Result<Vec<LocalUserId>, LemmyError> {
23 let post_id = comment.post_id;
24 let post = blocking(context.pool(), move |conn| Post::read(conn, post_id)).await??;
25 let actor = get_or_fetch_and_upsert_person(actor, context, request_counter).await?;
28 // Although mentions could be gotten from the post tags (they are included there), or the ccs,
29 // Its much easier to scrape them from the comment body, since the API has to do that
31 // TODO: for compatibility with other projects, it would be much better to read this from cc or tags
32 let mentions = scrape_text_for_mentions(&comment.content);
33 send_local_notifs(mentions, comment.clone(), actor, post, context.pool(), true).await
36 // TODO: in many call sites we are setting an empty vec for recipient_ids, we should get the actual
37 // recipient actors from somewhere
38 pub(crate) async fn send_websocket_message<
39 OP: ToString + Send + lemmy_websocket::OperationType + 'static,
41 comment_id: CommentId,
42 recipient_ids: Vec<LocalUserId>,
44 context: &LemmyContext,
45 ) -> Result<(), LemmyError> {
47 let comment_view = blocking(context.pool(), move |conn| {
48 CommentView::read(conn, comment_id, None)
52 let res = CommentResponse {
58 context.chat_server().do_send(SendComment {