mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51: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,21 +317,20 @@ impl Service {
|
||||||
) -> Result<(), crate::error::ServerNameChanged> {
|
) -> Result<(), crate::error::ServerNameChanged> {
|
||||||
use crate::error::ServerNameChanged as Error;
|
use crate::error::ServerNameChanged as Error;
|
||||||
|
|
||||||
if services()
|
let non_zero_users = services()
|
||||||
.users
|
.users
|
||||||
.count()
|
.count()
|
||||||
.map(|x| x > 0)
|
.map(|x| x > 0)
|
||||||
.map_err(Error::NonZeroUsers)?
|
.map_err(Error::NonZeroUsers)?;
|
||||||
{
|
|
||||||
let admin_bot = self.admin_bot_user_id.as_ref();
|
let admin_bot_exists = services()
|
||||||
if !services()
|
|
||||||
.users
|
.users
|
||||||
.exists(admin_bot)
|
.exists(&self.admin_bot_user_id)
|
||||||
.map_err(Error::AdminBotExists)?
|
.map_err(Error::AdminBotExists)?;
|
||||||
{
|
|
||||||
|
if non_zero_users && !admin_bot_exists {
|
||||||
return Err(Error::Renamed);
|
return Err(Error::Renamed);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue