Add a module callback to react to account data changes (#12327)

Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
This commit is contained in:
Brendan Abolivier 2022-04-01 11:22:48 +02:00 committed by GitHub
parent 4e900ece42
commit e4409301ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 250 additions and 2 deletions

View file

@ -65,6 +65,7 @@ from synapse.events.third_party_rules import (
ON_THREEPID_BIND_CALLBACK,
ON_USER_DEACTIVATION_STATUS_CHANGED_CALLBACK,
)
from synapse.handlers.account_data import ON_ACCOUNT_DATA_UPDATED_CALLBACK
from synapse.handlers.account_validity import (
IS_USER_EXPIRED_CALLBACK,
ON_LEGACY_ADMIN_REQUEST,
@ -216,6 +217,7 @@ class ModuleApi:
self._third_party_event_rules = hs.get_third_party_event_rules()
self._password_auth_provider = hs.get_password_auth_provider()
self._presence_router = hs.get_presence_router()
self._account_data_handler = hs.get_account_data_handler()
#################################################################################
# The following methods should only be called during the module's initialisation.
@ -376,6 +378,19 @@ class ModuleApi:
min_batch_size=min_batch_size,
)
def register_account_data_callbacks(
self,
*,
on_account_data_updated: Optional[ON_ACCOUNT_DATA_UPDATED_CALLBACK] = None,
) -> None:
"""Registers account data callbacks.
Added in Synapse 1.57.0.
"""
return self._account_data_handler.register_module_callbacks(
on_account_data_updated=on_account_data_updated,
)
def register_web_resource(self, path: str, resource: Resource) -> None:
"""Registers a web resource to be served at the given path.