mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-04 15:32:13 +02:00
Automatically invite a new registered user into public Matrix rooms
This commit is contained in:
@ -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")
|
||||
|
Reference in New Issue
Block a user