Skip to content

Commit 7aac7db

Browse files
committed
Set type of user_id on is_server_admin to str (#18786)
1 parent a8886d3 commit 7aac7db

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

changelog.d/18786.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix invalidation of storage cache that was broken in 1.135.0.

synapse/api/auth/internal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,4 @@ async def is_server_admin(self, requester: Requester) -> bool:
296296
Returns:
297297
True if the user is an admin
298298
"""
299-
return await self.store.is_server_admin(requester.user)
299+
return await self.store.is_server_admin(requester.user.to_string())

synapse/handlers/room_member.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ async def _remote_join(
19141914
check_complexity
19151915
and self.hs.config.server.limit_remote_rooms.admins_can_join
19161916
):
1917-
check_complexity = not await self.store.is_server_admin(user)
1917+
check_complexity = not await self.store.is_server_admin(user.to_string())
19181918

19191919
if check_complexity:
19201920
# Fetch the room complexity

synapse/module_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ async def is_user_admin(self, user_id: str) -> bool:
694694
Returns:
695695
True if the user is a server admin, False otherwise.
696696
"""
697-
return await self._store.is_server_admin(UserID.from_string(user_id))
697+
return await self._store.is_server_admin(user_id)
698698

699699
async def set_user_admin(self, user_id: str, admin: bool) -> None:
700700
"""Sets if a user is a server admin.

synapse/rest/admin/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ async def on_GET(
950950
"Only local users can be admins of this homeserver",
951951
)
952952

953-
is_admin = await self.store.is_server_admin(target_user)
953+
is_admin = await self.store.is_server_admin(target_user.to_string())
954954

955955
return HTTPStatus.OK, {"admin": is_admin}
956956

synapse/storage/databases/main/registration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ async def delete_account_validity_for_user(self, user_id: str) -> None:
674674
)
675675

676676
@cached(max_entries=100000)
677-
async def is_server_admin(self, user: UserID) -> bool:
677+
async def is_server_admin(self, user: str) -> bool:
678678
"""Determines if a user is an admin of this homeserver.
679679
680680
Args:
@@ -685,7 +685,7 @@ async def is_server_admin(self, user: UserID) -> bool:
685685
"""
686686
res = await self.db_pool.simple_select_one_onecol(
687687
table="users",
688-
keyvalues={"name": user.to_string()},
688+
keyvalues={"name": user},
689689
retcol="admin",
690690
allow_none=True,
691691
desc="is_server_admin",

synapse/visibility.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
RetentionPolicy,
5353
StateMap,
5454
StrCollection,
55-
UserID,
5655
get_domain_from_id,
5756
)
5857
from synapse.types.state import StateFilter
@@ -121,7 +120,7 @@ async def filter_events_for_client(
121120
if not (
122121
filter_send_to_client
123122
and client_config.return_soft_failed_events
124-
and await storage.main.is_server_admin(UserID.from_string(user_id))
123+
and await storage.main.is_server_admin(user_id)
125124
):
126125
events = [e for e in events if not e.internal_metadata.is_soft_failed()]
127126
if len(events_before_filtering) != len(events):

0 commit comments

Comments
 (0)