mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
refactor server_name check
This commit is contained in:
parent
12f2f89f81
commit
43018e5793
1 changed files with 10 additions and 11 deletions
|
|
@ -317,20 +317,19 @@ impl Service {
|
|||
) -> Result<(), crate::error::ServerNameChanged> {
|
||||
use crate::error::ServerNameChanged as Error;
|
||||
|
||||
if services()
|
||||
let non_zero_users = services()
|
||||
.users
|
||||
.count()
|
||||
.map(|x| x > 0)
|
||||
.map_err(Error::NonZeroUsers)?
|
||||
{
|
||||
let admin_bot = self.admin_bot_user_id.as_ref();
|
||||
if !services()
|
||||
.users
|
||||
.exists(admin_bot)
|
||||
.map_err(Error::AdminBotExists)?
|
||||
{
|
||||
return Err(Error::Renamed);
|
||||
}
|
||||
.map_err(Error::NonZeroUsers)?;
|
||||
|
||||
let admin_bot_exists = services()
|
||||
.users
|
||||
.exists(&self.admin_bot_user_id)
|
||||
.map_err(Error::AdminBotExists)?;
|
||||
|
||||
if non_zero_users && !admin_bot_exists {
|
||||
return Err(Error::Renamed);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue