feat: Add automatic room joining for new users
Introduces automatic room joining upon user registration. Updates configuration to include a list of rooms for auto-join. Enhances user onboarding experience by simplifying setup. Addresses onboarding workflow.
This commit is contained in:
parent
044f18b822
commit
a43914de62
4 changed files with 17 additions and 1 deletions
|
@ -13,3 +13,5 @@ email:
|
|||
admin:
|
||||
email: admin@your.server
|
||||
trust_proxy: false
|
||||
auto_join:
|
||||
- "!your_room_id:your.server"
|
||||
|
|
|
@ -49,6 +49,13 @@ 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",
|
||||
|
|
|
@ -144,12 +144,14 @@ class CompleteRegistrationView(FormView):
|
|||
registration.status = UserRegistration.STATUS_REQUESTED
|
||||
registration.registration_reason = registration_reason
|
||||
registration.save()
|
||||
|
||||
send_mail(
|
||||
"New Registration Request",
|
||||
f"Approve the new user {username}",
|
||||
settings.DEFAULT_FROM_EMAIL,
|
||||
[settings.ADMIN_EMAIL],
|
||||
)
|
||||
|
||||
return render(self.request, "registration/registration_pending.html")
|
||||
|
||||
form.add_error(None, "Registration failed.")
|
||||
|
|
|
@ -69,6 +69,11 @@ SYNAPSE_SERVER = config["synapse"]["server"]
|
|||
SYNAPSE_ADMIN_TOKEN = config["synapse"]["admin_token"]
|
||||
MATRIX_DOMAIN = config["synapse"]["domain"]
|
||||
|
||||
if "auto_join" in config:
|
||||
AUTO_JOIN = config["auto_join"]
|
||||
else:
|
||||
AUTO_JOIN = []
|
||||
|
||||
response = requests.get(
|
||||
f"{SYNAPSE_SERVER}/_matrix/client/r0/account/whoami",
|
||||
headers={"Authorization": f"Bearer {SYNAPSE_ADMIN_TOKEN}"},
|
||||
|
|
Loading…
Reference in a new issue