From 5bb74d538977077fca2a3b4e0783b910ca8491af Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 16 Nov 2024 20:23:20 +0100 Subject: [PATCH] fix: Reorders auto-join logic post-registration Moves auto-join functionality for newly registered users to occur after sending the registration approval email. Ensures user feedback through email is handled before attempting room joins, potentially improving user experience. --- src/synapse_registration/registration/signals.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/synapse_registration/registration/signals.py b/src/synapse_registration/registration/signals.py index c90ffe3..35ef56f 100644 --- a/src/synapse_registration/registration/signals.py +++ b/src/synapse_registration/registration/signals.py @@ -28,6 +28,13 @@ def handle_status_change(sender, instance, created, **kwargs): [settings.ADMIN_EMAIL], ) + for room in settings.AUTO_JOIN: + response = requests.post( + f"{settings.SYNAPSE_SERVER}/_synapse/admin/v1/join/{room}", + json={"user_id": f"@{instance.username}:{settings.MATRIX_DOMAIN}"}, + headers={"Authorization": f"Bearer {settings.SYNAPSE_ADMIN_TOKEN}"}, + ) + send_mail( "Registration Approved", f"Congratulations, {instance.username}! Your registration at {settings.MATRIX_DOMAIN} has been approved.", @@ -49,13 +56,6 @@ def handle_status_change(sender, instance, created, **kwargs): headers={"Authorization": f"Bearer {settings.SYNAPSE_ADMIN_TOKEN}"}, ) - for room in settings.AUTO_JOIN: - response = requests.post( - f"{settings.SYNAPSE_SERVER}/_synapse/admin/v1/join/{room}", - json={"user_id": f"@{instance.username}:{settings.MATRIX_DOMAIN}"}, - headers={"Authorization": f"Bearer {settings.SYNAPSE_ADMIN_TOKEN}"}, - ) - if response.status_code != 200: send_mail( "Deactivation Failed",