1
0
Fork 0
mirror of https://forgejo.ellis.link/continuwuation/continuwuity.git synced 2025-07-27 18:28:31 +00:00

feat: Forbid suspended users from sending reports

This commit is contained in:
nexy7574 2025-07-01 15:44:04 +01:00
parent 59912709aa
commit f49c73c031
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F

View file

@ -49,6 +49,9 @@ pub(crate) async fn report_room_route(
) -> Result<report_room::v3::Response> { ) -> Result<report_room::v3::Response> {
// user authentication // user authentication
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
}
if body.reason.as_ref().is_some_and(|s| s.len() > 750) { if body.reason.as_ref().is_some_and(|s| s.len() > 750) {
return Err(Error::BadRequest( return Err(Error::BadRequest(
@ -101,6 +104,9 @@ pub(crate) async fn report_event_route(
) -> Result<report_content::v3::Response> { ) -> Result<report_content::v3::Response> {
// user authentication // user authentication
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
}
delay_response().await; delay_response().await;
@ -148,6 +154,9 @@ pub(crate) async fn report_user_route(
) -> Result<report_user::v3::Response> { ) -> Result<report_user::v3::Response> {
// user authentication // user authentication
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if services.users.is_suspended(sender_user).await? {
return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
}
if body.reason.as_ref().is_some_and(|s| s.len() > 750) { if body.reason.as_ref().is_some_and(|s| s.len() > 750) {
return Err(Error::BadRequest( return Err(Error::BadRequest(