From 738e569ed22d662f62f82f54347b8faa87e1658b Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 14 Feb 2022 09:18:44 -0500 Subject: [PATCH] Require that modules register their callbacks using keyword arguments. (#11975) To allow for easier backwards/forwards compatibility by making it easier to add/remove callbacks. --- changelog.d/11975.bugfix | 1 + synapse/module_api/__init__.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 changelog.d/11975.bugfix diff --git a/changelog.d/11975.bugfix b/changelog.d/11975.bugfix new file mode 100644 index 000000000..076cb2b1e --- /dev/null +++ b/changelog.d/11975.bugfix @@ -0,0 +1 @@ +Require that modules register their callbacks using keyword arguments. diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index c63677930..d4fca3692 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -211,6 +211,7 @@ class ModuleApi: def register_spam_checker_callbacks( self, + *, check_event_for_spam: Optional[CHECK_EVENT_FOR_SPAM_CALLBACK] = None, user_may_join_room: Optional[USER_MAY_JOIN_ROOM_CALLBACK] = None, user_may_invite: Optional[USER_MAY_INVITE_CALLBACK] = None, @@ -245,6 +246,7 @@ class ModuleApi: def register_account_validity_callbacks( self, + *, is_user_expired: Optional[IS_USER_EXPIRED_CALLBACK] = None, on_user_registration: Optional[ON_USER_REGISTRATION_CALLBACK] = None, on_legacy_send_mail: Optional[ON_LEGACY_SEND_MAIL_CALLBACK] = None, @@ -265,6 +267,7 @@ class ModuleApi: def register_third_party_rules_callbacks( self, + *, check_event_allowed: Optional[CHECK_EVENT_ALLOWED_CALLBACK] = None, on_create_room: Optional[ON_CREATE_ROOM_CALLBACK] = None, check_threepid_can_be_invited: Optional[ @@ -289,6 +292,7 @@ class ModuleApi: def register_presence_router_callbacks( self, + *, get_users_for_states: Optional[GET_USERS_FOR_STATES_CALLBACK] = None, get_interested_users: Optional[GET_INTERESTED_USERS_CALLBACK] = None, ) -> None: @@ -303,6 +307,7 @@ class ModuleApi: def register_password_auth_provider_callbacks( self, + *, check_3pid_auth: Optional[CHECK_3PID_AUTH_CALLBACK] = None, on_logged_out: Optional[ON_LOGGED_OUT_CALLBACK] = None, auth_checkers: Optional[ @@ -327,6 +332,7 @@ class ModuleApi: def register_background_update_controller_callbacks( self, + *, on_update: ON_UPDATE_CALLBACK, default_batch_size: Optional[DEFAULT_BATCH_SIZE_CALLBACK] = None, min_batch_size: Optional[MIN_BATCH_SIZE_CALLBACK] = None,