|
@@ -112,23 +112,13 @@ class DeviceWorkerStore(SQLBaseStore):
|
|
|
if not has_changed:
|
|
|
return now_stream_id, []
|
|
|
|
|
|
- # We retrieve n+1 devices from the list of outbound pokes where n is
|
|
|
- # our outbound device update limit. We then check if the very last
|
|
|
- # device has the same stream_id as the second-to-last device. If so,
|
|
|
- # then we ignore all devices with that stream_id and only send the
|
|
|
- # devices with a lower stream_id.
|
|
|
- #
|
|
|
- # If when culling the list we end up with no devices afterwards, we
|
|
|
- # consider the device update to be too large, and simply skip the
|
|
|
- # stream_id; the rationale being that such a large device list update
|
|
|
- # is likely an error.
|
|
|
updates = yield self.db.runInteraction(
|
|
|
"get_device_updates_by_remote",
|
|
|
self._get_device_updates_by_remote_txn,
|
|
|
destination,
|
|
|
from_stream_id,
|
|
|
now_stream_id,
|
|
|
- limit + 1,
|
|
|
+ limit,
|
|
|
)
|
|
|
|
|
|
# Return an empty list if there are no updates
|
|
@@ -166,14 +156,6 @@ class DeviceWorkerStore(SQLBaseStore):
|
|
|
"device_id": verify_key.version,
|
|
|
}
|
|
|
|
|
|
- # if we have exceeded the limit, we need to exclude any results with the
|
|
|
- # same stream_id as the last row.
|
|
|
- if len(updates) > limit:
|
|
|
- stream_id_cutoff = updates[-1][2]
|
|
|
- now_stream_id = stream_id_cutoff - 1
|
|
|
- else:
|
|
|
- stream_id_cutoff = None
|
|
|
-
|
|
|
# Perform the equivalent of a GROUP BY
|
|
|
#
|
|
|
# Iterate through the updates list and copy non-duplicate
|
|
@@ -192,10 +174,6 @@ class DeviceWorkerStore(SQLBaseStore):
|
|
|
query_map = {}
|
|
|
cross_signing_keys_by_user = {}
|
|
|
for user_id, device_id, update_stream_id, update_context in updates:
|
|
|
- if stream_id_cutoff is not None and update_stream_id >= stream_id_cutoff:
|
|
|
- # Stop processing updates
|
|
|
- break
|
|
|
-
|
|
|
if (
|
|
|
user_id in master_key_by_user
|
|
|
and device_id == master_key_by_user[user_id]["device_id"]
|
|
@@ -218,17 +196,6 @@ class DeviceWorkerStore(SQLBaseStore):
|
|
|
if update_stream_id > previous_update_stream_id:
|
|
|
query_map[key] = (update_stream_id, update_context)
|
|
|
|
|
|
- # If we didn't find any updates with a stream_id lower than the cutoff, it
|
|
|
- # means that there are more than limit updates all of which have the same
|
|
|
- # steam_id.
|
|
|
-
|
|
|
- # That should only happen if a client is spamming the server with new
|
|
|
- # devices, in which case E2E isn't going to work well anyway. We'll just
|
|
|
- # skip that stream_id and return an empty list, and continue with the next
|
|
|
- # stream_id next time.
|
|
|
- if not query_map and not cross_signing_keys_by_user:
|
|
|
- return stream_id_cutoff, []
|
|
|
-
|
|
|
results = yield self._get_device_update_edus_by_remote(
|
|
|
destination, from_stream_id, query_map
|
|
|
)
|