22
22
# Types for callbacks to be registered via the module api
23
23
IS_USER_EXPIRED_CALLBACK = Callable [[str ], Awaitable [Optional [bool ]]]
24
24
ON_USER_REGISTRATION_CALLBACK = Callable [[str ], Awaitable ]
25
+ ON_USER_LOGIN_CALLBACK = Callable [[str , Optional [str ], Optional [str ]], Awaitable ]
25
26
# Temporary hooks to allow for a transition from `/_matrix/client` endpoints
26
27
# to `/_synapse/client/account_validity`. See `register_callbacks` below.
27
28
ON_LEGACY_SEND_MAIL_CALLBACK = Callable [[str ], Awaitable ]
@@ -33,6 +34,7 @@ class AccountValidityModuleApiCallbacks:
33
34
def __init__ (self ) -> None :
34
35
self .is_user_expired_callbacks : List [IS_USER_EXPIRED_CALLBACK ] = []
35
36
self .on_user_registration_callbacks : List [ON_USER_REGISTRATION_CALLBACK ] = []
37
+ self .on_user_login_callbacks : List [ON_USER_LOGIN_CALLBACK ] = []
36
38
self .on_legacy_send_mail_callback : Optional [ON_LEGACY_SEND_MAIL_CALLBACK ] = None
37
39
self .on_legacy_renew_callback : Optional [ON_LEGACY_RENEW_CALLBACK ] = None
38
40
@@ -44,6 +46,7 @@ def register_callbacks(
44
46
self ,
45
47
is_user_expired : Optional [IS_USER_EXPIRED_CALLBACK ] = None ,
46
48
on_user_registration : Optional [ON_USER_REGISTRATION_CALLBACK ] = None ,
49
+ on_user_login : Optional [ON_USER_LOGIN_CALLBACK ] = None ,
47
50
on_legacy_send_mail : Optional [ON_LEGACY_SEND_MAIL_CALLBACK ] = None ,
48
51
on_legacy_renew : Optional [ON_LEGACY_RENEW_CALLBACK ] = None ,
49
52
on_legacy_admin_request : Optional [ON_LEGACY_ADMIN_REQUEST ] = None ,
@@ -55,6 +58,9 @@ def register_callbacks(
55
58
if on_user_registration is not None :
56
59
self .on_user_registration_callbacks .append (on_user_registration )
57
60
61
+ if on_user_login is not None :
62
+ self .on_user_login_callbacks .append (on_user_login )
63
+
58
64
# The builtin account validity feature exposes 3 endpoints (send_mail, renew, and
59
65
# an admin one). As part of moving the feature into a module, we need to change
60
66
# the path from /_matrix/client/unstable/account_validity/... to
0 commit comments