Implement MSC3890: Remotely silence local notifications (#14775)
This commit is contained in:
parent
52ae80dd1a
commit
54cd90ea60
|
@ -0,0 +1 @@
|
||||||
|
Implement support for MSC3890: Remotely silence local notifications.
|
|
@ -102,6 +102,8 @@ experimental_features:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Filtering /messages by relation type.
|
# Filtering /messages by relation type.
|
||||||
msc3874_enabled: true
|
msc3874_enabled: true
|
||||||
|
# Enable deleting device-specific notification settings stored in account data
|
||||||
|
msc3890_enabled: true
|
||||||
# Enable removing account data support
|
# Enable removing account data support
|
||||||
msc3391_enabled: true
|
msc3391_enabled: true
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ fi
|
||||||
|
|
||||||
extra_test_args=()
|
extra_test_args=()
|
||||||
|
|
||||||
test_tags="synapse_blacklist,msc3787,msc3874,msc3391"
|
test_tags="synapse_blacklist,msc3787,msc3874,msc3890,msc3391"
|
||||||
|
|
||||||
# All environment variables starting with PASS_ will be shared.
|
# All environment variables starting with PASS_ will be shared.
|
||||||
# (The prefix is stripped off before reaching the container.)
|
# (The prefix is stripped off before reaching the container.)
|
||||||
|
|
|
@ -17,6 +17,7 @@ from typing import Any, Optional
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, RoomVersions
|
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, RoomVersions
|
||||||
|
from synapse.config import ConfigError
|
||||||
from synapse.config._base import Config
|
from synapse.config._base import Config
|
||||||
from synapse.types import JsonDict
|
from synapse.types import JsonDict
|
||||||
|
|
||||||
|
@ -93,6 +94,9 @@ class ExperimentalConfig(Config):
|
||||||
# MSC2815 (allow room moderators to view redacted event content)
|
# MSC2815 (allow room moderators to view redacted event content)
|
||||||
self.msc2815_enabled: bool = experimental.get("msc2815_enabled", False)
|
self.msc2815_enabled: bool = experimental.get("msc2815_enabled", False)
|
||||||
|
|
||||||
|
# MSC3391: Removing account data.
|
||||||
|
self.msc3391_enabled = experimental.get("msc3391_enabled", False)
|
||||||
|
|
||||||
# MSC3773: Thread notifications
|
# MSC3773: Thread notifications
|
||||||
self.msc3773_enabled: bool = experimental.get("msc3773_enabled", False)
|
self.msc3773_enabled: bool = experimental.get("msc3773_enabled", False)
|
||||||
|
|
||||||
|
@ -127,6 +131,17 @@ class ExperimentalConfig(Config):
|
||||||
"msc3886_endpoint", None
|
"msc3886_endpoint", None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# MSC3890: Remotely silence local notifications
|
||||||
|
# Note: This option requires "experimental_features.msc3391_enabled" to be
|
||||||
|
# set to "true", in order to communicate account data deletions to clients.
|
||||||
|
self.msc3890_enabled: bool = experimental.get("msc3890_enabled", False)
|
||||||
|
if self.msc3890_enabled and not self.msc3391_enabled:
|
||||||
|
raise ConfigError(
|
||||||
|
"Option 'experimental_features.msc3391' must be set to 'true' to "
|
||||||
|
"enable 'experimental_features.msc3890'. MSC3391 functionality is "
|
||||||
|
"required to communicate account data deletions to clients."
|
||||||
|
)
|
||||||
|
|
||||||
# MSC3912: Relation-based redactions.
|
# MSC3912: Relation-based redactions.
|
||||||
self.msc3912_enabled: bool = experimental.get("msc3912_enabled", False)
|
self.msc3912_enabled: bool = experimental.get("msc3912_enabled", False)
|
||||||
|
|
||||||
|
|
|
@ -346,6 +346,7 @@ class DeviceHandler(DeviceWorkerHandler):
|
||||||
super().__init__(hs)
|
super().__init__(hs)
|
||||||
|
|
||||||
self.federation_sender = hs.get_federation_sender()
|
self.federation_sender = hs.get_federation_sender()
|
||||||
|
self._account_data_handler = hs.get_account_data_handler()
|
||||||
self._storage_controllers = hs.get_storage_controllers()
|
self._storage_controllers = hs.get_storage_controllers()
|
||||||
|
|
||||||
self.device_list_updater = DeviceListUpdater(hs, self)
|
self.device_list_updater = DeviceListUpdater(hs, self)
|
||||||
|
@ -502,7 +503,7 @@ class DeviceHandler(DeviceWorkerHandler):
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Delete access tokens and e2e keys for each device. Not optimised as it is not
|
# Delete data specific to each device. Not optimised as it is not
|
||||||
# considered as part of a critical path.
|
# considered as part of a critical path.
|
||||||
for device_id in device_ids:
|
for device_id in device_ids:
|
||||||
await self._auth_handler.delete_access_tokens_for_user(
|
await self._auth_handler.delete_access_tokens_for_user(
|
||||||
|
@ -512,6 +513,14 @@ class DeviceHandler(DeviceWorkerHandler):
|
||||||
user_id=user_id, device_id=device_id
|
user_id=user_id, device_id=device_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.hs.config.experimental.msc3890_enabled:
|
||||||
|
# Remove any local notification settings for this device in accordance
|
||||||
|
# with MSC3890.
|
||||||
|
await self._account_data_handler.remove_account_data_for_user(
|
||||||
|
user_id,
|
||||||
|
f"org.matrix.msc3890.local_notification_settings.{device_id}",
|
||||||
|
)
|
||||||
|
|
||||||
await self.notify_device_update(user_id, device_ids)
|
await self.notify_device_update(user_id, device_ids)
|
||||||
|
|
||||||
async def update_device(self, user_id: str, device_id: str, content: dict) -> None:
|
async def update_device(self, user_id: str, device_id: str, content: dict) -> None:
|
||||||
|
|
Loading…
Reference in New Issue