diff options
author | Erik Johnston <erik@matrix.org> | 2022-12-05 20:19:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-05 15:19:14 -0500 |
commit | cee9445884eb62c070fb0b03a112a862e8dea7c4 (patch) | |
tree | e373ccf91b0b42fe285d077282a332f841b82281 /synapse/handlers/presence.py | |
parent | Compare to the earliest known stream pos in the stream change cache. (#14435) (diff) | |
download | synapse-cee9445884eb62c070fb0b03a112a862e8dea7c4.tar.xz |
Better return type for `get_all_entities_changed` (#14604)
Help callers from using the return value incorrectly by ensuring that callers explicitly check if there was a cache hit or not.
Diffstat (limited to 'synapse/handlers/presence.py')
-rw-r--r-- | synapse/handlers/presence.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 1799174c2f..2af90b25a3 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -1692,10 +1692,12 @@ class PresenceEventSource(EventSource[int, UserPresenceState]): if from_key is not None: # First get all users that have had a presence update - updated_users = stream_change_cache.get_all_entities_changed(from_key) + result = stream_change_cache.get_all_entities_changed(from_key) # Cross-reference users we're interested in with those that have had updates. - if updated_users is not None: + if result.hit: + updated_users = result.entities + # If we have the full list of changes for presence we can # simply check which ones share a room with the user. get_updates_counter.labels("stream").inc() @@ -1767,9 +1769,9 @@ class PresenceEventSource(EventSource[int, UserPresenceState]): updated_users = None if from_key: # Only return updates since the last sync - updated_users = self.store.presence_stream_cache.get_all_entities_changed( - from_key - ) + result = self.store.presence_stream_cache.get_all_entities_changed(from_key) + if result.hit: + updated_users = result.entities if updated_users is not None: # Get the actual presence update for each change |