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

Commit 51be04b

Browse files
committed
Guard processing device list updates with experimental option
1 parent 4b67118 commit 51be04b

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

synapse/config/experimental.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def read_config(self, config: JsonDict, **kwargs):
5959
"msc3202_device_masquerading", False
6060
)
6161

62-
# Portion of MSC3202 related to transaction extensions:
63-
# sending one-time key counts and fallback key usage to application services.
62+
# The portion of MSC3202 related to transaction extensions:
63+
# sending device list changes, one-time key counts and fallback key
64+
# usage to application services.
6465
self.msc3202_transaction_extensions: bool = experimental.get(
6566
"msc3202_transaction_extensions", False
6667
)

synapse/handlers/appservice.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def __init__(self, hs: "HomeServer"):
5858
self._msc2409_to_device_messages_enabled = (
5959
hs.config.experimental.msc2409_to_device_messages_enabled
6060
)
61+
self._msc3202_transaction_extensions_enabled = (
62+
hs.config.experimental.msc3202_transaction_extensions
63+
)
6164

6265
self.current_max = 0
6366
self.is_processing = False
@@ -204,9 +207,9 @@ def notify_interested_services_ephemeral(
204207
Args:
205208
stream_key: The stream the event came from.
206209
207-
`stream_key` can be "typing_key", "receipt_key", "presence_key" or
208-
"to_device_key". Any other value for `stream_key` will cause this function
209-
to return early.
210+
`stream_key` can be "typing_key", "receipt_key", "presence_key",
211+
"to_device_key" or "device_list_key". Any other value for `stream_key`
212+
will cause this function to return early.
210213
211214
Ephemeral events will only be pushed to appservices that have opted into
212215
receiving them by setting `push_ephemeral` to true in their registration
@@ -230,6 +233,7 @@ def notify_interested_services_ephemeral(
230233
"receipt_key",
231234
"presence_key",
232235
"to_device_key",
236+
"device_list_key",
233237
):
234238
return
235239

@@ -253,15 +257,37 @@ def notify_interested_services_ephemeral(
253257
):
254258
return
255259

260+
# Ignore device lists if the feature flag is not enabled
261+
if (
262+
stream_key == "device_list_key"
263+
and not self._msc3202_transaction_extensions_enabled
264+
):
265+
return
266+
256267
# Check whether there are any appservices which have registered to receive
257268
# ephemeral events.
258269
#
259270
# Note that whether these events are actually relevant to these appservices
260271
# is decided later on.
272+
services = self.store.get_app_services()
261273
services = [
262274
service
263-
for service in self.store.get_app_services()
264-
if service.supports_ephemeral
275+
for service in services
276+
# Different stream keys require different support booleans
277+
if (
278+
stream_key
279+
in (
280+
"typing_key",
281+
"receipt_key",
282+
"presence_key",
283+
"to_device_key",
284+
)
285+
and service.supports_ephemeral
286+
)
287+
or (
288+
stream_key == "device_list_key"
289+
and service.msc3202_transaction_extensions
290+
)
265291
]
266292
if not services:
267293
# Bail out early if none of the target appservices have explicitly registered

0 commit comments

Comments
 (0)