From ee335e37127e5259ba83af4c64142bbdac0fd481 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Sun, 14 Apr 2024 01:52:06 +0200 Subject: [PATCH] bicep/synapse: fix registering users via smtp --- .../matrix/smtp-authenticator/smtp_auth_provider.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py b/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py index ae4e04d8..85d39760 100644 --- a/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py +++ b/hosts/bicep/services/matrix/smtp-authenticator/smtp_auth_provider.py @@ -7,6 +7,9 @@ from synapse import module_api import re +import logging +logger = logging.getLogger(__name__) + class SMTPAuthProvider: def __init__(self, config: dict, api: module_api): self.api = api @@ -43,8 +46,13 @@ class SMTPAuthProvider: if result == True: userid = self.api.get_qualified_user_id(username) - if not self.api.check_user_exists(userid): - self.api.register_user(username) + + userid = await self.api.check_user_exists(userid) + if not userid: + logger.info(f"user did not exist, registering {username}") + userid = await self.api.register_user(username) + logger.info(f"registered userid: {userid}") return (userid, None) else: + logger.info("returning None") return None