1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-28 03:34:16 +01:00

Raise 404 when room doesn't exist

Raise 404 "Room not found" when changing or accessing room visibility
settings (`GET` and `PUT
/_matrix/client/r0/directory/list/room/{roomId}`).
See issue #290
This commit is contained in:
Max Cohen 2022-09-10 18:14:29 +02:00 committed by Timo Kösters
parent 2627ca5e3d
commit 6fd39ae174
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4

View file

@ -85,6 +85,14 @@ pub async fn set_room_visibility_route(
) -> Result<set_room_visibility::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if !db.rooms.exists(&body.room_id)? {
// Return 404 if the room doesn't exist
return Err(Error::BadRequest(
ErrorKind::NotFound,
"Room not found",
));
}
match &body.visibility {
room::Visibility::Public => {
services().rooms.directory.set_public(&body.room_id)?;
@ -108,6 +116,15 @@ pub async fn set_room_visibility_route(
pub async fn get_room_visibility_route(
body: Ruma<get_room_visibility::v3::IncomingRequest>,
) -> Result<get_room_visibility::v3::Response> {
if !db.rooms.exists(&body.room_id)? {
// Return 404 if the room doesn't exist
return Err(Error::BadRequest(
ErrorKind::NotFound,
"Room not found",
));
}
Ok(get_room_visibility::v3::Response {
visibility: if services().rooms.directory.is_public_room(&body.room_id)? {
room::Visibility::Public