mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 22:14:57 -04:00
Directly lookup local membership instead of getting all members in a room first (get_users_in_room
mis-use) (#13608)
See https://github.com/matrix-org/synapse/pull/13575#discussion_r953023755
This commit is contained in:
parent
b93bd95e8a
commit
d58615c82c
8 changed files with 60 additions and 17 deletions
|
@ -102,6 +102,10 @@ class ServerNoticesManager:
|
|||
Returns:
|
||||
The room's ID, or None if no room could be found.
|
||||
"""
|
||||
# If there is no server notices MXID, then there is no server notices room
|
||||
if self.server_notices_mxid is None:
|
||||
return None
|
||||
|
||||
rooms = await self._store.get_rooms_for_local_user_where_membership_is(
|
||||
user_id, [Membership.INVITE, Membership.JOIN]
|
||||
)
|
||||
|
@ -111,8 +115,10 @@ class ServerNoticesManager:
|
|||
# be joined. This is kinda deliberate, in that if somebody somehow
|
||||
# manages to invite the system user to a room, that doesn't make it
|
||||
# the server notices room.
|
||||
user_ids = await self._store.get_users_in_room(room.room_id)
|
||||
if len(user_ids) <= 2 and self.server_notices_mxid in user_ids:
|
||||
is_server_notices_room = await self._store.check_local_user_in_room(
|
||||
user_id=self.server_notices_mxid, room_id=room.room_id
|
||||
)
|
||||
if is_server_notices_room:
|
||||
# we found a room which our user shares with the system notice
|
||||
# user
|
||||
return room.room_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue