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

Add script to fix channel permissions

This commit is contained in:
Yohann D'ANELLO
2020-10-29 17:22:07 +01:00
parent 316e4eefc1
commit 09a2947095
3 changed files with 52 additions and 5 deletions

View File

@ -0,0 +1,25 @@
from asgiref.sync import async_to_sync
from nio import RoomPreset
from corres2math.matrix import Matrix, RoomVisibility
from django.core.management import BaseCommand
from registration.models import AdminRegistration
class Command(BaseCommand):
def handle(self, *args, **options):
Matrix.set_display_name("Bot des Correspondances")
if not async_to_sync(Matrix.resolve_room_alias)("#faq:correspondances-maths.fr"):
Matrix.create_room(
visibility=RoomVisibility.public,
alias="faq",
name="FAQ",
topic="Posez toutes vos questions ici !",
federate=False,
preset=RoomPreset.public_chat,
)
for admin in AdminRegistration.objects.all():
Matrix.set_room_power_level("#faq:correspondances-maths.fr",
f"@{admin.matrix_username}:correspondances-maths.fr", 95)