1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-21 05:58:22 +02:00

Create #annonces channel

This commit is contained in:
Yohann D'ANELLO
2020-10-29 19:41:07 +01:00
parent 09a2947095
commit 3265c1fc1b
2 changed files with 35 additions and 2 deletions

View File

@ -3,7 +3,7 @@ from nio import RoomPreset
from corres2math.matrix import Matrix, RoomVisibility
from django.core.management import BaseCommand
from registration.models import AdminRegistration
from registration.models import AdminRegistration, Registration
class Command(BaseCommand):
@ -20,6 +20,24 @@ class Command(BaseCommand):
preset=RoomPreset.public_chat,
)
if not async_to_sync(Matrix.resolve_room_alias)("#annonces:correspondances-maths.fr"):
Matrix.create_room(
visibility=RoomVisibility.public,
alias="annonces",
name="Annonces",
topic="Informations importantes des Correspondances",
federate=False,
preset=RoomPreset.public_chat,
)
Matrix.set_room_power_level_event("#annonces:correspondances-maths.fr", "events_default", 50)
for r in Registration.objects.all():
Matrix.invite("#annonces:correspondances-maths.fr", f"@{r.matrix_username}:correspondances-maths.fr")
Matrix.invite("#faq:correspondances-maths.fr", f"@{r.matrix_username}:correspondances-maths.fr")
for admin in AdminRegistration.objects.all():
Matrix.set_room_power_level("#annonces:correspondances-maths.fr",
f"@{admin.matrix_username}:correspondances-maths.fr", 95)
Matrix.set_room_power_level("#faq:correspondances-maths.fr",
f"@{admin.matrix_username}:correspondances-maths.fr", 95)