diff options
author | Erik Johnston <erik@matrix.org> | 2018-07-10 18:12:39 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-07-10 18:12:39 +0100 |
commit | 6ccefef07a0eb366d64076bf6052b94409262981 (patch) | |
tree | 7b21eaac759a814801cc100672d4b8d524671c63 /synapse/storage/receipts.py | |
parent | Newsfile (diff) | |
download | synapse-6ccefef07a0eb366d64076bf6052b94409262981.tar.xz |
Use 'is not None' and add comments
Diffstat (limited to 'synapse/storage/receipts.py')
-rw-r--r-- | synapse/storage/receipts.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/storage/receipts.py b/synapse/storage/receipts.py index 401400d927..33fc2b9b31 100644 --- a/synapse/storage/receipts.py +++ b/synapse/storage/receipts.py @@ -140,7 +140,9 @@ class ReceiptsWorkerStore(SQLBaseStore): """ room_ids = set(room_ids) - if from_key: + if from_key is not None: + # Only ask the database about rooms where there have been new + # receipts added since `from_key` room_ids = yield self._receipts_stream_cache.get_entities_changed( room_ids, from_key ) @@ -163,7 +165,9 @@ class ReceiptsWorkerStore(SQLBaseStore): Returns: list: A list of receipts. """ - if from_key: + if from_key is not None: + # Check the cache first to see if any new receipts have been added + # since`from_key`. If not we can no-op. if not self._receipts_stream_cache.has_entity_changed(room_id, from_key): defer.succeed([]) |