Stablize MSC2409

This commit is contained in:
Half-Shot 2024-10-28 12:04:59 +00:00
parent 69e9b75373
commit 830e3a1df3
5 changed files with 27 additions and 7 deletions

View file

@ -86,6 +86,7 @@ class ApplicationService:
rate_limited: bool = True,
ip_range_whitelist: Optional[IPSet] = None,
supports_ephemeral: bool = False,
supports_ephemeral_legacy: bool = False,
msc3202_transaction_extensions: bool = False,
):
self.token = token
@ -99,6 +100,7 @@ class ApplicationService:
self.id = id
self.ip_range_whitelist = ip_range_whitelist
self.supports_ephemeral = supports_ephemeral
self.supports_ephemeral_legacy = supports_ephemeral_legacy
self.msc3202_transaction_extensions = msc3202_transaction_extensions
if "|" in self.id:

View file

@ -353,7 +353,16 @@ class ApplicationServiceApi(SimpleHttpClient):
if service.supports_ephemeral:
body.update(
{
# TODO: Update to stable prefixes once MSC2409 completes FCP merge.
"ephemeral": ephemeral,
# NOTE: This is actually https://github.com/matrix-org/matrix-spec-proposals/blob/tulir/appservice-to-device/proposals/4203-appservice-to-device.md
# but for legacy reasons uses an older MSC number.
"de.sorunome.msc2409.to_device": to_device_messages,
}
)
elif service.supports_ephemeral_legacy:
# Support to be removed in a future spec version.
body.update(
{
"de.sorunome.msc2409.ephemeral": ephemeral,
"de.sorunome.msc2409.to_device": to_device_messages,
}

View file

@ -170,7 +170,14 @@ def _load_appservice(
if as_info.get("ip_range_whitelist"):
ip_range_whitelist = IPSet(as_info.get("ip_range_whitelist"))
supports_ephemeral = as_info.get("de.sorunome.msc2409.push_ephemeral", False)
supports_ephemeral = as_info.get("receive_ephemeral", False)
# For ASes that haven't transitioned to the stable fields yet
supports_ephemeral_legacy = False
if not supports_ephemeral:
supports_ephemeral_legacy = as_info.get(
"de.sorunome.msc2409.push_ephemeral", False
)
# Opt-in flag for the MSC3202-specific transactional behaviour.
# When enabled, appservice transactions contain the following information:
@ -194,5 +201,6 @@ def _load_appservice(
rate_limited=rate_limited,
ip_range_whitelist=ip_range_whitelist,
supports_ephemeral=supports_ephemeral,
supports_ephemeral_legacy=supports_ephemeral_legacy,
msc3202_transaction_extensions=msc3202_transaction_extensions,
)

View file

@ -294,7 +294,9 @@ class ExperimentalConfig(Config):
# MSC3266 (room summary api)
self.msc3266_enabled: bool = experimental.get("msc3266_enabled", False)
# MSC2409 (this setting only relates to optionally sending to-device messages).
# MSC4203 (Sending to-device events to appservices).
# NOTE: This used to be used to be part of MSC2409 but was split out, hence the config
# key not matching the MSC.
# Presence, typing and read receipt EDUs are already sent to application services that
# have opted in to receive them. If enabled, this adds to-device messages to that list.
self.msc2409_to_device_messages_enabled: bool = experimental.get(

View file

@ -242,9 +242,8 @@ class ApplicationServicesHandler:
will cause this function to return early.
Ephemeral events will only be pushed to appservices that have opted into
receiving them by setting `push_ephemeral` to true in their registration
file. Note that while MSC2409 is experimental, this option is called
`de.sorunome.msc2409.push_ephemeral`.
receiving them by setting `recieve_ephemeral` to true in their registration
file.
Appservices will only receive ephemeral events that fall within their
registered user and room namespaces.
@ -588,7 +587,7 @@ class ApplicationServicesHandler:
new_token,
)
# According to MSC2409, we'll need to add 'to_user_id' and 'to_device_id' fields
# According to MSC4203, we'll need to add 'to_user_id' and 'to_device_id' fields
# to the event JSON so that the application service will know which user/device
# combination this messages was intended for.
#