Remove redundant service.users.is_admin
This commit is contained in:
@@ -167,7 +167,7 @@ pub(super) async fn deactivate_all(&self, no_leave_rooms: bool, force: bool) ->
|
|||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
| Ok(user_id) => {
|
| Ok(user_id) => {
|
||||||
if self.services.users.is_admin(&user_id).await && !force {
|
if self.services.admin.user_is_admin(&user_id).await && !force {
|
||||||
self.services
|
self.services
|
||||||
.admin
|
.admin
|
||||||
.send_text(&format!(
|
.send_text(&format!(
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||||||
.server
|
.server
|
||||||
.config
|
.config
|
||||||
.lockdown_public_room_directory
|
.lockdown_public_room_directory
|
||||||
&& !services.users.is_admin(sender_user).await
|
&& !services.admin.user_is_admin(sender_user).await
|
||||||
&& body.appservice_info.is_none()
|
&& body.appservice_info.is_none()
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ pub(crate) async fn banned_room_check(
|
|||||||
orig_room_id: Option<&RoomOrAliasId>,
|
orig_room_id: Option<&RoomOrAliasId>,
|
||||||
client_ip: IpAddr,
|
client_ip: IpAddr,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
if services.users.is_admin(user_id).await {
|
if services.admin.user_is_admin(user_id).await {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -807,7 +807,10 @@ async fn can_publish_directory_check(
|
|||||||
.lockdown_public_room_directory
|
.lockdown_public_room_directory
|
||||||
|| body.appservice_info.is_some()
|
|| body.appservice_info.is_some()
|
||||||
|| body.visibility != room::Visibility::Public
|
|| body.visibility != room::Visibility::Public
|
||||||
|| services.users.is_admin(body.sender_user()).await
|
|| services
|
||||||
|
.admin
|
||||||
|
.user_is_admin(body.sender_user())
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -832,7 +835,10 @@ async fn can_create_room_check(
|
|||||||
) -> Result {
|
) -> Result {
|
||||||
if !services.config.allow_room_creation
|
if !services.config.allow_room_creation
|
||||||
&& body.appservice_info.is_none()
|
&& body.appservice_info.is_none()
|
||||||
&& !services.users.is_admin(body.sender_user()).await
|
&& !services
|
||||||
|
.admin
|
||||||
|
.user_is_admin(body.sender_user())
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("Room creation has been disabled.",)));
|
return Err!(Request(Forbidden("Room creation has been disabled.",)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ pub(crate) async fn invite_check(
|
|||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
) -> Result {
|
) -> Result {
|
||||||
if !services.users.is_admin(sender_user).await && services.config.block_non_admin_invites {
|
if !services.admin.user_is_admin(sender_user).await && services.config.block_non_admin_invites
|
||||||
|
{
|
||||||
warn!("{sender_user} is not an admin and attempted to send an invite to {room_id}");
|
warn!("{sender_user} is not an admin and attempted to send an invite to {room_id}");
|
||||||
return Err!(Request(Forbidden("Invites are not allowed on this server.")));
|
return Err!(Request(Forbidden("Invites are not allowed on this server.")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,12 +147,14 @@ pub(crate) async fn create_invite_route(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if services.metadata.is_banned(&body.room_id).await
|
if services.metadata.is_banned(&body.room_id).await
|
||||||
&& !services.users.is_admin(&invited_user).await
|
&& !services.admin.user_is_admin(&invited_user).await
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("This room is banned on this homeserver.")));
|
return Err!(Request(Forbidden("This room is banned on this homeserver.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if services.config.block_non_admin_invites && !services.users.is_admin(&invited_user).await {
|
if services.config.block_non_admin_invites
|
||||||
|
&& !services.admin.user_is_admin(&invited_user).await
|
||||||
|
{
|
||||||
return Err!(Request(Forbidden("This server does not allow room invites.")));
|
return Err!(Request(Forbidden("This server does not allow room invites.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,12 +107,6 @@ impl Service {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a user is an admin
|
|
||||||
#[inline]
|
|
||||||
pub async fn is_admin(&self, user_id: &UserId) -> bool {
|
|
||||||
self.services.admin.user_is_admin(user_id).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new user account on this homeserver.
|
/// Create a new user account on this homeserver.
|
||||||
///
|
///
|
||||||
/// User origin is by default "password" (meaning that it will login using
|
/// User origin is by default "password" (meaning that it will login using
|
||||||
|
|||||||
Reference in New Issue
Block a user