feat(db/rooms): disable leaving from admin room for last user
This commit is contained in:
parent
c67f95ebff
commit
da2dbd2877
1 changed files with 15 additions and 0 deletions
|
@ -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.",
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue