Set type of user_id on is_server_admin to str (#18786)
This commit is contained in:
parent
a8886d3351
commit
7aac7db652
1
changelog.d/18786.bugfix
Normal file
1
changelog.d/18786.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix invalidation of storage cache that was broken in 1.135.0.
|
||||
@ -296,4 +296,4 @@ class InternalAuth(BaseAuth):
|
||||
Returns:
|
||||
True if the user is an admin
|
||||
"""
|
||||
return await self.store.is_server_admin(requester.user)
|
||||
return await self.store.is_server_admin(requester.user.to_string())
|
||||
|
||||
@ -1914,7 +1914,7 @@ class RoomMemberMasterHandler(RoomMemberHandler):
|
||||
check_complexity
|
||||
and self.hs.config.server.limit_remote_rooms.admins_can_join
|
||||
):
|
||||
check_complexity = not await self.store.is_server_admin(user)
|
||||
check_complexity = not await self.store.is_server_admin(user.to_string())
|
||||
|
||||
if check_complexity:
|
||||
# Fetch the room complexity
|
||||
|
||||
@ -694,7 +694,7 @@ class ModuleApi:
|
||||
Returns:
|
||||
True if the user is a server admin, False otherwise.
|
||||
"""
|
||||
return await self._store.is_server_admin(UserID.from_string(user_id))
|
||||
return await self._store.is_server_admin(user_id)
|
||||
|
||||
async def set_user_admin(self, user_id: str, admin: bool) -> None:
|
||||
"""Sets if a user is a server admin.
|
||||
|
||||
@ -950,7 +950,7 @@ class UserAdminServlet(RestServlet):
|
||||
"Only local users can be admins of this homeserver",
|
||||
)
|
||||
|
||||
is_admin = await self.store.is_server_admin(target_user)
|
||||
is_admin = await self.store.is_server_admin(target_user.to_string())
|
||||
|
||||
return HTTPStatus.OK, {"admin": is_admin}
|
||||
|
||||
|
||||
@ -674,7 +674,7 @@ class RegistrationWorkerStore(StatsStore, CacheInvalidationWorkerStore):
|
||||
)
|
||||
|
||||
@cached(max_entries=100000)
|
||||
async def is_server_admin(self, user: UserID) -> bool:
|
||||
async def is_server_admin(self, user: str) -> bool:
|
||||
"""Determines if a user is an admin of this homeserver.
|
||||
|
||||
Args:
|
||||
@ -685,7 +685,7 @@ class RegistrationWorkerStore(StatsStore, CacheInvalidationWorkerStore):
|
||||
"""
|
||||
res = await self.db_pool.simple_select_one_onecol(
|
||||
table="users",
|
||||
keyvalues={"name": user.to_string()},
|
||||
keyvalues={"name": user},
|
||||
retcol="admin",
|
||||
allow_none=True,
|
||||
desc="is_server_admin",
|
||||
|
||||
@ -52,7 +52,6 @@ from synapse.types import (
|
||||
RetentionPolicy,
|
||||
StateMap,
|
||||
StrCollection,
|
||||
UserID,
|
||||
get_domain_from_id,
|
||||
)
|
||||
from synapse.types.state import StateFilter
|
||||
@ -121,7 +120,7 @@ async def filter_events_for_client(
|
||||
if not (
|
||||
filter_send_to_client
|
||||
and client_config.return_soft_failed_events
|
||||
and await storage.main.is_server_admin(UserID.from_string(user_id))
|
||||
and await storage.main.is_server_admin(user_id)
|
||||
):
|
||||
events = [e for e in events if not e.internal_metadata.is_soft_failed()]
|
||||
if len(events_before_filtering) != len(events):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user