use crate::{check_report_reason, Perform};
use actix_web::web::Data;
use lemmy_api_common::{
+ context::LemmyContext,
private_message::{CreatePrivateMessageReport, PrivateMessageReportResponse},
- utils::get_local_user_view_from_jwt,
+ utils::{get_local_user_view_from_jwt, send_new_report_email_to_admins},
+ websocket::UserOperation,
};
use lemmy_db_schema::{
newtypes::CommunityId,
};
use lemmy_db_views::structs::PrivateMessageReportView;
use lemmy_utils::{error::LemmyError, ConnectionId};
-use lemmy_websocket::{messages::SendModRoomMessage, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)]
impl Perform for CreatePrivateMessageReport {
let private_message_report_view =
PrivateMessageReportView::read(context.pool(), report.id).await?;
+ // Email the admins
+ if local_site.reports_email_admins {
+ send_new_report_email_to_admins(
+ &private_message_report_view.creator.name,
+ &private_message_report_view.private_message_creator.name,
+ context.pool(),
+ context.settings(),
+ )
+ .await?;
+ }
+
let res = PrivateMessageReportResponse {
private_message_report_view,
};
- context.chat_server().do_send(SendModRoomMessage {
- op: UserOperation::CreatePrivateMessageReport,
- response: res.clone(),
- community_id: CommunityId(0),
- websocket_id,
- });
+ context
+ .chat_server()
+ .send_mod_room_message(
+ UserOperation::CreatePrivateMessageReport,
+ &res,
+ CommunityId(0),
+ websocket_id,
+ )
+ .await?;
// TODO: consider federating this