Skip to content

Commit 3a01e9d

Browse files
Set type of user_id on is_server_admin to str (#18786)
1 parent e587b8c commit 3a01e9d

File tree

7 files changed

+8
-10
lines changed

7 files changed

+8
-10
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
@@ -1921,7 +1921,7 @@ async def _remote_join(
19211921
check_complexity
19221922
and self.hs.config.server.limit_remote_rooms.admins_can_join
19231923
):
1924-
check_complexity = not await self.store.is_server_admin(user)
1924+
check_complexity = not await self.store.is_server_admin(user.to_string())
19251925

19261926
if check_complexity:
19271927
# Fetch the room complexity

synapse/module_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ async def is_user_admin(self, user_id: str) -> bool:
761761
Returns:
762762
True if the user is a server admin, False otherwise.
763763
"""
764-
return await self._store.is_server_admin(UserID.from_string(user_id))
764+
return await self._store.is_server_admin(user_id)
765765

766766
async def set_user_admin(self, user_id: str, admin: bool) -> None:
767767
"""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
@@ -1000,7 +1000,7 @@ async def on_GET(
10001000
"Only local users can be admins of this homeserver",
10011001
)
10021002

1003-
is_admin = await self.store.is_server_admin(target_user)
1003+
is_admin = await self.store.is_server_admin(target_user.to_string())
10041004

10051005
return HTTPStatus.OK, {"admin": is_admin}
10061006

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 & 4 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
@@ -120,9 +119,7 @@ async def filter_events_for_client(
120119
# Default case is to *exclude* soft-failed events
121120
events = [e for e in events if not e.internal_metadata.is_soft_failed()]
122121
client_config = await storage.main.get_admin_client_config_for_user(user_id)
123-
if filter_send_to_client and await storage.main.is_server_admin(
124-
UserID.from_string(user_id)
125-
):
122+
if filter_send_to_client and await storage.main.is_server_admin(user_id):
126123
if client_config.return_soft_failed_events:
127124
# The user has requested that all events be included, so do that.
128125
# We copy the list for mutation safety.

0 commit comments

Comments
 (0)