mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-05 22:44:10 -04:00
Fix registering a device on an account with lots of devices (#15348)
Fixes up #15183
This commit is contained in:
parent
5350b5d04d
commit
f0d8f66eaa
4 changed files with 56 additions and 3 deletions
|
@ -1638,19 +1638,22 @@ class DeviceBackgroundUpdateStore(SQLBaseStore):
|
|||
"""
|
||||
|
||||
rows = await self.db_pool.execute(
|
||||
"check_too_many_devices_for_user_last_seen", None, sql, (user_id,)
|
||||
"check_too_many_devices_for_user_last_seen",
|
||||
None,
|
||||
sql,
|
||||
user_id,
|
||||
)
|
||||
if rows:
|
||||
max_last_seen = max(rows[0][0], max_last_seen)
|
||||
|
||||
# Fetch the devices to delete.
|
||||
sql = """
|
||||
SELECT DISTINCT device_id FROM devices
|
||||
SELECT device_id FROM devices
|
||||
LEFT JOIN e2e_device_keys_json USING (user_id, device_id)
|
||||
WHERE
|
||||
user_id = ?
|
||||
AND NOT hidden
|
||||
AND last_seen < ?
|
||||
AND last_seen <= ?
|
||||
AND key_json IS NULL
|
||||
ORDER BY last_seen
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue