diff options
author | Mathieu Velten <matmaul@gmail.com> | 2023-06-23 15:22:00 +0200 |
---|---|---|
committer | Mathieu Velten <matmaul@gmail.com> | 2023-06-23 15:22:00 +0200 |
commit | 921fa8f9ceafdef2c204f600348e383403c8ddfe (patch) | |
tree | 4c2cd64aa7f62577b937b439accd894f8caae7b5 /synapse | |
parent | Ignore key requests if the device inbox is already big (diff) | |
download | synapse-921fa8f9ceafdef2c204f600348e383403c8ddfe.tar.xz |
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/storage/databases/main/deviceinbox.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/synapse/storage/databases/main/deviceinbox.py b/synapse/storage/databases/main/deviceinbox.py index 1eb4501c99..b13d5bd48e 100644 --- a/synapse/storage/databases/main/deviceinbox.py +++ b/synapse/storage/databases/main/deviceinbox.py @@ -816,7 +816,7 @@ class DeviceInboxWorkerStore(SQLBaseStore): local_by_user_then_device = {} for user_id, messages_by_device in messages_by_user_then_device.items(): - inboxes_size = {} + inbox_sizes = {} if size_limit: sql = """ SELECT device_id, COUNT(*) FROM device_inbox @@ -825,7 +825,7 @@ class DeviceInboxWorkerStore(SQLBaseStore): """ txn.execute(sql, (user_id,)) for r in txn: - inboxes_size[r[0]] = r[1] + inbox_sizes[r[0]] = r[1] messages_json_for_user = {} devices = list(messages_by_device.keys()) @@ -842,10 +842,7 @@ class DeviceInboxWorkerStore(SQLBaseStore): message_json = json_encoder.encode(messages_by_device["*"]) for device_id in devices: - if ( - size_limit is None - or inboxes_size.get(device_id, 0) <= size_limit - ): + if size_limit is None or inbox_sizes.get(device_id, 0) < size_limit: # Add the message for all devices for this user on this # server. messages_json_for_user[device_id] = message_json @@ -881,10 +878,7 @@ class DeviceInboxWorkerStore(SQLBaseStore): ) message_json = json_encoder.encode(msg) - if ( - size_limit is None - or inboxes_size.get(device_id, 0) <= size_limit - ): + if size_limit is None or inbox_sizes.get(device_id, 0) < size_limit: messages_json_for_user[device_id] = message_json if messages_json_for_user: |