summary refs log tree commit diff
path: root/synapse/module_api/callbacks
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/module_api/callbacks')
-rw-r--r--synapse/module_api/callbacks/__init__.py2
-rw-r--r--synapse/module_api/callbacks/account_data_callbacks.py35
2 files changed, 37 insertions, 0 deletions
diff --git a/synapse/module_api/callbacks/__init__.py b/synapse/module_api/callbacks/__init__.py

index add3f2938d..6419607f92 100644 --- a/synapse/module_api/callbacks/__init__.py +++ b/synapse/module_api/callbacks/__init__.py
@@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from .account_data_callbacks import AccountDataModuleApiCallbacks from .account_validity_callbacks import AccountValidityModuleApiCallbacks from .background_updater_callbacks import BackgroundUpdaterModuleApiCallbacks from .password_auth_provider_callbacks import PasswordAuthProviderModuleApiCallbacks @@ -26,6 +27,7 @@ __all__ = [ class ModuleApiCallbacks: def __init__(self) -> None: + self.account_data = AccountDataModuleApiCallbacks() self.account_validity = AccountValidityModuleApiCallbacks() self.background_updater = BackgroundUpdaterModuleApiCallbacks() self.password_auth_provider = PasswordAuthProviderModuleApiCallbacks() diff --git a/synapse/module_api/callbacks/account_data_callbacks.py b/synapse/module_api/callbacks/account_data_callbacks.py new file mode 100644
index 0000000000..3321fa185a --- /dev/null +++ b/synapse/module_api/callbacks/account_data_callbacks.py
@@ -0,0 +1,35 @@ +# Copyright 2015, 2016 OpenMarket Ltd +# Copyright 2021, 2023 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from typing import Awaitable, Callable, List, Optional + +from synapse.types import JsonDict + +ON_ACCOUNT_DATA_UPDATED_CALLBACK = Callable[ + [str, Optional[str], str, JsonDict], Awaitable +] + + +class AccountDataModuleApiCallbacks: + def __init__(self) -> None: + self.on_account_data_updated_callbacks: List[ + ON_ACCOUNT_DATA_UPDATED_CALLBACK + ] = [] + + def register_callbacks( + self, on_account_data_updated: Optional[ON_ACCOUNT_DATA_UPDATED_CALLBACK] = None + ) -> None: + """Register callbacks from modules.""" + if on_account_data_updated is not None: + self.on_account_data_updated_callbacks.append(on_account_data_updated)