1 use lemmy_api_common::{blocking, person::PrivateMessageResponse};
2 use lemmy_db_schema::PrivateMessageId;
3 use lemmy_db_views::{local_user_view::LocalUserView, private_message_view::PrivateMessageView};
4 use lemmy_utils::LemmyError;
5 use lemmy_websocket::{messages::SendUserRoomMessage, LemmyContext, UserOperationCrud};
7 pub mod create_or_update;
11 async fn send_websocket_message(
12 private_message_id: PrivateMessageId,
13 op: UserOperationCrud,
14 context: &LemmyContext,
15 ) -> Result<(), LemmyError> {
16 let message = blocking(context.pool(), move |conn| {
17 PrivateMessageView::read(conn, private_message_id)
20 let res = PrivateMessageResponse {
21 private_message_view: message,
24 // Send notifications to the local recipient, if one exists
25 let recipient_id = res.private_message_view.recipient.id;
26 let local_recipient_id = blocking(context.pool(), move |conn| {
27 LocalUserView::read_person(conn, recipient_id)
33 context.chat_server().do_send(SendUserRoomMessage {