Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4c6fd81

Browse files
author
Sean Quah
committed
Stop updating the converted_to_destinations column
From now on, the `converted_to_destinations` column indicates rows that need converting to outbound pokes, but does not indicate whether the conversion has already taken place. Signed-off-by: Sean Quah <seanq@matrix.org>
1 parent 437d6d1 commit 4c6fd81

File tree

3 files changed

+10
-37
lines changed

3 files changed

+10
-37
lines changed

synapse/handlers/device.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,6 @@ async def _handle_new_device_update_async(self) -> None:
738738
user_id=user_id,
739739
device_id=device_id,
740740
room_id=room_id,
741-
stream_id=stream_id,
742741
hosts=hosts,
743742
context=opentracing_context,
744743
)
@@ -860,7 +859,6 @@ async def handle_room_un_partial_stated(self, room_id: str) -> None:
860859
user_id=user_id,
861860
device_id=device_id,
862861
room_id=room_id,
863-
stream_id=None,
864862
hosts=potentially_changed_hosts,
865863
context=None,
866864
)

synapse/storage/databases/main/devices.py

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,49 +2072,25 @@ async def add_device_list_outbound_pokes(
20722072
user_id: str,
20732073
device_id: str,
20742074
room_id: str,
2075-
stream_id: Optional[int],
20762075
hosts: Collection[str],
20772076
context: Optional[Dict[str, str]],
20782077
) -> None:
20792078
"""Queue the device update to be sent to the given set of hosts,
20802079
calculated from the room ID.
2081-
2082-
Marks the associated row in `device_lists_changes_in_room` as handled,
2083-
if `stream_id` is provided.
20842080
"""
2081+
if not hosts:
2082+
return
20852083

20862084
def add_device_list_outbound_pokes_txn(
20872085
txn: LoggingTransaction, stream_ids: List[int]
20882086
) -> None:
2089-
if hosts:
2090-
self._add_device_outbound_poke_to_stream_txn(
2091-
txn,
2092-
user_id=user_id,
2093-
device_id=device_id,
2094-
hosts=hosts,
2095-
stream_ids=stream_ids,
2096-
context=context,
2097-
)
2098-
2099-
if stream_id:
2100-
self.db_pool.simple_update_txn(
2101-
txn,
2102-
table="device_lists_changes_in_room",
2103-
keyvalues={
2104-
"user_id": user_id,
2105-
"device_id": device_id,
2106-
"stream_id": stream_id,
2107-
"room_id": room_id,
2108-
},
2109-
updatevalues={"converted_to_destinations": True},
2110-
)
2111-
2112-
if not hosts:
2113-
# If there are no hosts then we don't try and generate stream IDs.
2114-
return await self.db_pool.runInteraction(
2115-
"add_device_list_outbound_pokes",
2116-
add_device_list_outbound_pokes_txn,
2117-
[],
2087+
self._add_device_outbound_poke_to_stream_txn(
2088+
txn,
2089+
user_id=user_id,
2090+
device_id=device_id,
2091+
hosts=hosts,
2092+
stream_ids=stream_ids,
2093+
context=context,
21182094
)
21192095

21202096
async with self._device_list_id_gen.get_next_mult(len(hosts)) as stream_ids:

tests/storage/test_devices.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def add_device_change(self, user_id, device_ids, host):
2828
"""
2929

3030
for device_id in device_ids:
31-
stream_id = self.get_success(
31+
self.get_success(
3232
self.store.add_device_change_to_streams(
3333
user_id, [device_id], ["!some:room"]
3434
)
@@ -39,7 +39,6 @@ def add_device_change(self, user_id, device_ids, host):
3939
user_id=user_id,
4040
device_id=device_id,
4141
room_id="!some:room",
42-
stream_id=stream_id,
4342
hosts=[host],
4443
context={},
4544
)

0 commit comments

Comments
 (0)