Skip to content

Commit

Permalink
add a qurey for banned users
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Oct 4, 2024
1 parent d3d3794 commit 110aa10
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,27 @@ def get_users_server_still_shares_room_with_txn(

return {row[0] for row in txn}

async def get_rooms_user_currently_banned_from(
self, user_id: str
) -> FrozenSet[str]:
"""Returns a set of room_ids the user is currently banned from.
If a remote user only returns rooms this server is currently
participating in.
"""
room_ids = await self.db_pool.simple_select_onecol(
table="current_state_events",
keyvalues={
"type": EventTypes.Member,
"membership": Membership.BAN,
"state_key": user_id,
},
retcol="room_id",
desc="get_rooms_user_currently_banned_from",
)

return frozenset(room_ids)

@cached(max_entries=500000, iterable=True)
async def get_rooms_for_user(self, user_id: str) -> FrozenSet[str]:
"""Returns a set of room_ids the user is currently joined to.
Expand Down

0 comments on commit 110aa10

Please sign in to comment.