Handle the case of remote users leaving a partial join room for device lists (#13885)

This commit is contained in:
Erik Johnston 2022-09-27 13:01:08 +01:00 committed by GitHub
parent 85e161631a
commit e8318a4333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 108 deletions

View file

@ -662,31 +662,37 @@ class RoomMemberWorkerStore(EventsWorkerStore):
if not user_ids:
return set()
def _get_users_server_still_shares_room_with_txn(
txn: LoggingTransaction,
) -> Set[str]:
sql = """
SELECT state_key FROM current_state_events
WHERE
type = 'm.room.member'
AND membership = 'join'
AND %s
GROUP BY state_key
"""
clause, args = make_in_list_sql_clause(
self.database_engine, "state_key", user_ids
)
txn.execute(sql % (clause,), args)
return {row[0] for row in txn}
return await self.db_pool.runInteraction(
"get_users_server_still_shares_room_with",
_get_users_server_still_shares_room_with_txn,
self.get_users_server_still_shares_room_with_txn,
user_ids,
)
def get_users_server_still_shares_room_with_txn(
self,
txn: LoggingTransaction,
user_ids: Collection[str],
) -> Set[str]:
if not user_ids:
return set()
sql = """
SELECT state_key FROM current_state_events
WHERE
type = 'm.room.member'
AND membership = 'join'
AND %s
GROUP BY state_key
"""
clause, args = make_in_list_sql_clause(
self.database_engine, "state_key", user_ids
)
txn.execute(sql % (clause,), args)
return {row[0] for row in txn}
@cancellable
async def get_rooms_for_user(
self, user_id: str, on_invalidate: Optional[Callable[[], None]] = None