mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-05 02:06:52 +00:00
Automatically invite a new registered user into public Matrix rooms
This commit is contained in:
parent
2273cbfbc6
commit
52c8a836f1
@ -9,7 +9,9 @@ class RegistrationConfig(AppConfig):
|
||||
name = 'registration'
|
||||
|
||||
def ready(self):
|
||||
from registration.signals import set_username, send_email_link, create_admin_registration
|
||||
from registration.signals import create_admin_registration, invite_to_public_rooms, \
|
||||
set_username, send_email_link
|
||||
pre_save.connect(set_username, "auth.User")
|
||||
pre_save.connect(send_email_link, "auth.User")
|
||||
post_save.connect(create_admin_registration, "auth.User")
|
||||
post_save.connect(invite_to_public_rooms, "registration.Registration")
|
||||
|
@ -1,6 +1,7 @@
|
||||
from corres2math.lists import get_sympa_client
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from corres2math.matrix import Matrix
|
||||
from .models import AdminRegistration, Registration
|
||||
|
||||
|
||||
@ -38,3 +39,12 @@ def create_admin_registration(instance, **_):
|
||||
"""
|
||||
if instance.is_superuser:
|
||||
AdminRegistration.objects.get_or_create(user=instance)
|
||||
|
||||
|
||||
def invite_to_public_rooms(instance: Registration, **_):
|
||||
"""
|
||||
When a user got registered, automatically invite the Matrix user into public rooms.
|
||||
"""
|
||||
if not instance.pk:
|
||||
Matrix.invite("#annonces:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
|
||||
Matrix.invite("#faq:correspondances-maths.fr", f"@{instance.matrix_username}:correspondances-maths.fr")
|
||||
|
Loading…
Reference in New Issue
Block a user