mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-09-30 16:48:26 -04:00
When server leaves room check for stale device lists. (#6801)
When a server leaves a room it may stop sharing a room with remote users, and thus not get any updates to their device lists. So we need to check for this case and delete those device lists from the cache. We don't need to do this if we stop sharing a room because the remote user leaves the room, because we track that case via looking at membership changes.
This commit is contained in:
parent
c80a9fe13d
commit
a5bab2d058
3 changed files with 83 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
from typing import Iterable, List
|
||||
from typing import Iterable, List, Set
|
||||
|
||||
from six import iteritems, itervalues
|
||||
|
||||
|
@ -40,7 +40,7 @@ from synapse.storage.roommember import (
|
|||
ProfileInfo,
|
||||
RoomsForUser,
|
||||
)
|
||||
from synapse.types import get_domain_from_id
|
||||
from synapse.types import Collection, get_domain_from_id
|
||||
from synapse.util.async_helpers import Linearizer
|
||||
from synapse.util.caches import intern_string
|
||||
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks, cachedList
|
||||
|
@ -439,6 +439,39 @@ class RoomMemberWorkerStore(EventsWorkerStore):
|
|||
|
||||
return results
|
||||
|
||||
async def get_users_server_still_shares_room_with(
|
||||
self, user_ids: Collection[str]
|
||||
) -> Set[str]:
|
||||
"""Given a list of users return the set that the server still share a
|
||||
room with.
|
||||
"""
|
||||
|
||||
if not user_ids:
|
||||
return set()
|
||||
|
||||
def _get_users_server_still_shares_room_with_txn(txn):
|
||||
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 set(row[0] for row in txn)
|
||||
|
||||
return await self.db.runInteraction(
|
||||
"get_users_server_still_shares_room_with",
|
||||
_get_users_server_still_shares_room_with_txn,
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_rooms_for_user(self, user_id, on_invalidate=None):
|
||||
"""Returns a set of room_ids the user is currently joined to.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue