From 2e98ba3ed8aeedf0a73e7c851b0e9979c4e9a641 Mon Sep 17 00:00:00 2001 From: Ginger Date: Wed, 22 Apr 2026 10:33:16 -0400 Subject: [PATCH] fix: Increase max length for report reasons --- src/api/client/report.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/api/client/report.rs b/src/api/client/report.rs index 6cd8bd44f..3917754dc 100644 --- a/src/api/client/report.rs +++ b/src/api/client/report.rs @@ -25,6 +25,8 @@ struct Report { reason: String, } +const MAX_REASON_LENGTH: usize = 2000; + /// # `POST /_matrix/client/v3/rooms/{roomId}/report` /// /// Reports an abusive room to homeserver admins @@ -39,10 +41,10 @@ pub(crate) async fn report_room_route( return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); } - if body.reason.len() > 750 { - return Err!(Request( - InvalidParam("Reason too long, should be 750 characters or fewer",) - )); + if body.reason.len() > MAX_REASON_LENGTH { + return Err!(Request(InvalidParam( + "Reason too long, should be {MAX_REASON_LENGTH} bytes or fewer", + ))); } delay_response().await; @@ -139,10 +141,10 @@ pub(crate) async fn report_user_route( return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); } - if body.reason.len() > 750 { - return Err!(Request( - InvalidParam("Reason too long, should be 750 characters or fewer",) - )); + if body.reason.len() > MAX_REASON_LENGTH { + return Err!(Request(InvalidParam( + "Reason too long, should be {MAX_REASON_LENGTH} bytes or fewer", + ))); } delay_response().await; @@ -194,10 +196,10 @@ async fn is_event_report_valid( return Err!(Request(NotFound("Event ID does not belong to the reported room",))); } - if reason.len() > 750 { - return Err!(Request( - InvalidParam("Reason too long, should be 750 characters or fewer",) - )); + if reason.len() > MAX_REASON_LENGTH { + return Err!(Request(InvalidParam( + "Reason too long, should be {MAX_REASON_LENGTH} bytes or fewer", + ))); } if !services