diff options
author | Mathieu Velten <mathieuv@matrix.org> | 2022-08-02 15:18:57 +0200 |
---|---|---|
committer | Mathieu Velten <mathieuv@matrix.org> | 2022-08-02 15:18:57 +0200 |
commit | 5de1f166f9615b64c8861e2a5e38a574b34f533c (patch) | |
tree | d158a5ba93897b4096b7a6504c68f26b4f787e03 | |
parent | Apply suggestions from code review (diff) | |
download | synapse-5de1f166f9615b64c8861e2a5e38a574b34f533c.tar.xz |
Address comment
-rw-r--r-- | synapse/storage/databases/main/deviceinbox.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/synapse/storage/databases/main/deviceinbox.py b/synapse/storage/databases/main/deviceinbox.py index 0bd7ceefeb..79e3862d5f 100644 --- a/synapse/storage/databases/main/deviceinbox.py +++ b/synapse/storage/databases/main/deviceinbox.py @@ -218,6 +218,9 @@ class DeviceInboxWorkerStore(SQLBaseStore): * The last-processed stream ID. Subsequent calls of this function with the same device should pass this value as 'from_stream_id'. """ + if limit == 0: + return {}, from_stream_id + ( user_id_device_id_to_messages, last_processed_stream_id, @@ -229,6 +232,10 @@ class DeviceInboxWorkerStore(SQLBaseStore): limit=limit, ) + if not user_id_device_id_to_messages: + # There were no messages! + return [], to_stream_id + # Extract the messages, no need to return the user and device ID again to_device_messages = user_id_device_id_to_messages.get((user_id, device_id), []) @@ -293,9 +300,6 @@ class DeviceInboxWorkerStore(SQLBaseStore): "without a specific user_id/device_id" ) - if limit == 0: - return {}, from_stream_id - user_ids_to_query: Set[str] = set() device_ids_to_query: Set[str] = set() |