feat(db/rooms): disable leaving from admin room for last user

This commit is contained in:
AndSDev 2022-08-31 07:11:28 +00:00
parent c67f95ebff
commit da2dbd2877

View file

@ -716,6 +716,21 @@ impl Service {
"Conduit user cannot leave from admins room.",
));
}
let count = services()
.rooms
.state_cache
.room_members(room_id)
.filter_map(|m| m.ok())
.filter(|m| m.server_name() == services().globals.server_name())
.count();
if count < 3 {
warn!("Last admin cannot leave from admins room");
return Err(Error::BadRequest(
ErrorKind::Forbidden,
"Last admin cannot leave from admins room.",
));
}
}
}
}