use actix_web::{web, web::Data};
use captcha::Captcha;
-use lemmy_api_common::{comment::*, community::*, person::*, post::*, site::*, websocket::*};
-use lemmy_utils::{error::LemmyError, ConnectionId};
+use lemmy_api_common::{
+ comment::*,
+ community::*,
+ person::*,
+ post::*,
+ private_message::*,
+ site::*,
+ websocket::*,
+};
+use lemmy_utils::{error::LemmyError, utils::check_slurs, ConnectionId};
use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};
use serde::Deserialize;
mod post;
mod post_report;
mod private_message;
+mod private_message_report;
mod site;
mod websocket;
UserOperation::MarkPersonMentionAsRead => {
do_websocket_operation::<MarkPersonMentionAsRead>(context, id, op, data).await
}
+ UserOperation::MarkCommentReplyAsRead => {
+ do_websocket_operation::<MarkCommentReplyAsRead>(context, id, op, data).await
+ }
UserOperation::MarkAllAsRead => {
do_websocket_operation::<MarkAllAsRead>(context, id, op, data).await
}
UserOperation::MarkPrivateMessageAsRead => {
do_websocket_operation::<MarkPrivateMessageAsRead>(context, id, op, data).await
}
+ UserOperation::CreatePrivateMessageReport => {
+ do_websocket_operation::<CreatePrivateMessageReport>(context, id, op, data).await
+ }
+ UserOperation::ResolvePrivateMessageReport => {
+ do_websocket_operation::<ResolvePrivateMessageReport>(context, id, op, data).await
+ }
+ UserOperation::ListPrivateMessageReports => {
+ do_websocket_operation::<ListPrivateMessageReports>(context, id, op, data).await
+ }
// Site ops
UserOperation::GetModlog => do_websocket_operation::<GetModlog>(context, id, op, data).await,
}
// Comment ops
- UserOperation::MarkCommentAsRead => {
- do_websocket_operation::<MarkCommentAsRead>(context, id, op, data).await
- }
UserOperation::SaveComment => {
do_websocket_operation::<SaveComment>(context, id, op, data).await
}
base64::encode(concat_letters)
}
+/// Check size of report and remove whitespace
+pub(crate) fn check_report_reason(reason: &str, context: &LemmyContext) -> Result<(), LemmyError> {
+ check_slurs(reason, &context.settings().slur_regex())?;
+ if reason.is_empty() {
+ return Err(LemmyError::from_message("report_reason_required"));
+ }
+ if reason.chars().count() > 1000 {
+ return Err(LemmyError::from_message("report_too_long"));
+ }
+ Ok(())
+}
+
#[cfg(test)]
mod tests {
use lemmy_api_common::utils::check_validator_time;