use single global function for server name local and user local checking

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-28 11:35:25 -04:00 committed by June
parent 8f17d965b2
commit 9931e60050
14 changed files with 77 additions and 41 deletions

View file

@ -9,7 +9,9 @@ use super::RoomModerationCommand;
use crate::{
api::client_server::{get_alias_helper, leave_room},
service::admin::{escape_html, Service},
services, Result,
services,
utils::user_id::user_is_local,
Result,
};
pub(crate) async fn process(command: RoomModerationCommand, body: Vec<&str>) -> Result<RoomMessageEventContent> {
@ -102,11 +104,10 @@ pub(crate) async fn process(command: RoomModerationCommand, body: Vec<&str>) ->
.room_members(&room_id)
.filter_map(|user| {
user.ok().filter(|local_user| {
local_user.server_name() == services().globals.server_name()
user_is_local(local_user)
// additional wrapped check here is to avoid adding remote users
// who are in the admin room to the list of local users (would fail auth check)
&& (local_user.server_name()
== services().globals.server_name()
&& (user_is_local(local_user)
&& services()
.users
.is_admin(local_user)