Skip to content
Snippets Groups Projects
Commit a85ebdea authored by 🥺's avatar 🥺 :transgender_flag: Committed by 🥺
Browse files

require sender_user being in the reporting room for /report events

parent efa63081
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@
const RANDOM_USER_ID_LENGTH: usize = 10;
/// # `GET /_matrix/client/r0/register/available`
/// # `GET /_matrix/client/v3/register/available`
///
/// Checks if a username is valid and available on this server.
///
......
......@@ -361,7 +361,7 @@ pub async fn unban_user_route(
Ok(unban_user::v3::Response::new())
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/forget`
/// # `POST /_matrix/client/v3/rooms/{roomId}/forget`
///
/// Forgets about a room.
///
......
......@@ -5,7 +5,7 @@
int,
};
/// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}`
/// # `POST /_matrix/client/v3/rooms/{roomId}/report/{eventId}`
///
/// Reports an inappropriate event to homeserver admins
///
......@@ -24,6 +24,20 @@ pub async fn report_event_route(
}
};
// check if reporting user is in the reporting room
if !services()
.rooms
.state_cache
.room_members(&pdu.room_id)
.filter_map(|r| r.ok())
.any(|user_id| user_id == *sender_user)
{
return Err(Error::BadRequest(
ErrorKind::NotFound,
"You are not in the room you are reporting.",
));
}
if let Some(true) = body.score.map(|s| s > int!(0) || s < int!(-100)) {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment