1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-05 02:06:52 +00:00

Fix auto-invitation in Matrix public rooms

This commit is contained in:
Yohann D'ANELLO 2020-11-02 15:46:31 +01:00
parent c80355f2bc
commit be17d11581
2 changed files with 5 additions and 2 deletions

View File

@ -15,3 +15,6 @@ class RegistrationConfig(AppConfig):
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")
post_save.connect(invite_to_public_rooms, "registration.StudentRegistration")
post_save.connect(invite_to_public_rooms, "registration.CoachRegistration")
post_save.connect(invite_to_public_rooms, "registration.AdminRegistration")

View File

@ -41,11 +41,11 @@ def create_admin_registration(instance, **_):
AdminRegistration.objects.get_or_create(user=instance)
def invite_to_public_rooms(instance: Registration, **_):
def invite_to_public_rooms(instance: Registration, created: bool, **_):
"""
When a user got registered, automatically invite the Matrix user into public rooms.
"""
if not instance.pk:
if not created:
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")
Matrix.invite("#je-cherche-une-equip:correspondances-maths.fr",