mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-17 23:42:33 +01:00
Stop synapse from saving messages in device_inbox for hidden devices. (#10097)
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
This commit is contained in:
parent
e320f5dba3
commit
29ffd680bf
2 changed files with 7 additions and 2 deletions
1
changelog.d/10097.bugfix
Normal file
1
changelog.d/10097.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a long-standing bug which allowed hidden devices to receive to-device messages, resulting in unnecessary database bloat.
|
|
@ -489,10 +489,12 @@ class DeviceInboxWorkerStore(SQLBaseStore):
|
||||||
devices = list(messages_by_device.keys())
|
devices = list(messages_by_device.keys())
|
||||||
if len(devices) == 1 and devices[0] == "*":
|
if len(devices) == 1 and devices[0] == "*":
|
||||||
# Handle wildcard device_ids.
|
# Handle wildcard device_ids.
|
||||||
|
# We exclude hidden devices (such as cross-signing keys) here as they are
|
||||||
|
# not expected to receive to-device messages.
|
||||||
devices = self.db_pool.simple_select_onecol_txn(
|
devices = self.db_pool.simple_select_onecol_txn(
|
||||||
txn,
|
txn,
|
||||||
table="devices",
|
table="devices",
|
||||||
keyvalues={"user_id": user_id},
|
keyvalues={"user_id": user_id, "hidden": False},
|
||||||
retcol="device_id",
|
retcol="device_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -505,10 +507,12 @@ class DeviceInboxWorkerStore(SQLBaseStore):
|
||||||
if not devices:
|
if not devices:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# We exclude hidden devices (such as cross-signing keys) here as they are
|
||||||
|
# not expected to receive to-device messages.
|
||||||
rows = self.db_pool.simple_select_many_txn(
|
rows = self.db_pool.simple_select_many_txn(
|
||||||
txn,
|
txn,
|
||||||
table="devices",
|
table="devices",
|
||||||
keyvalues={"user_id": user_id},
|
keyvalues={"user_id": user_id, "hidden": False},
|
||||||
column="device_id",
|
column="device_id",
|
||||||
iterable=devices,
|
iterable=devices,
|
||||||
retcols=("device_id",),
|
retcols=("device_id",),
|
||||||
|
|
Loading…
Reference in a new issue