mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 17:02:24 +00:00
Integrate BigBlueButton and whiteboard in pool rooms
This commit is contained in:
parent
97761e07a9
commit
56ad352e64
@ -5,6 +5,7 @@ import os
|
||||
|
||||
from asgiref.sync import async_to_sync
|
||||
from django.core.management import BaseCommand
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import activate
|
||||
from participation.models import Team, Tournament
|
||||
from registration.models import AdminRegistration, Registration, VolunteerRegistration
|
||||
@ -320,6 +321,17 @@ class Command(BaseCommand):
|
||||
Matrix.set_room_avatar(f"#poule-{slug}-{pool.id}:tfjm.org", avatar_uri)
|
||||
Matrix.set_room_avatar(f"#poule-{slug}-{pool.id}-jurys:tfjm.org", avatar_uri)
|
||||
|
||||
url_params = urlencode(dict(url="https://visio.animath.live/b/XXX-XXX-XXX",
|
||||
isAudioConf='false', displayName='$matrix_display_name',
|
||||
avatarUrl='$matrix_avatar_url', userId='$matrix_user_id')) \
|
||||
.replace("%24", "$")
|
||||
Matrix.add_integration(f"#poule-{slug}-{pool.id}:tfjm.org",
|
||||
f"https://scalar.vector.im/api/widgets/bigbluebutton.html?{url_params}",
|
||||
f"bbb-{slug}-{pool.id}", "bigbluebutton", "BigBlueButton", str(pool))
|
||||
Matrix.add_integration(f"#poule-{slug}-{pool.id}:tfjm.org",
|
||||
f"https://board.tfjm.org/boards/{slug}-{pool.id}", f"board-{slug}-{pool.id}",
|
||||
"customwidget", "Tableau", str(pool))
|
||||
|
||||
# Invite admins and give permissions
|
||||
for admin in AdminRegistration.objects.all():
|
||||
Matrix.invite(f"#poule-{slug}-{pool.id}:tfjm.org", f"@{admin.matrix_username}:tfjm.org")
|
||||
|
@ -263,6 +263,46 @@ class Matrix:
|
||||
content=content,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@async_to_sync
|
||||
async def add_integration(cls, room_id: str, widget_url: str, state_key: str,
|
||||
widget_type: str = "customwidget", widget_name: str = "Custom widget",
|
||||
widget_title: str = ""):
|
||||
client = await cls._get_client()
|
||||
if room_id.startswith("#"):
|
||||
room_id = await cls.resolve_room_alias(room_id)
|
||||
content = {
|
||||
"type": widget_type,
|
||||
"url": widget_url,
|
||||
"name": widget_name,
|
||||
"data": {
|
||||
"curl": widget_url,
|
||||
"title": widget_title,
|
||||
},
|
||||
"creatorUserId": client.user,
|
||||
"roomId": room_id,
|
||||
"id": state_key,
|
||||
}
|
||||
return await client.room_put_state(
|
||||
room_id=room_id,
|
||||
event_type="im.vector.modular.widgets",
|
||||
content=content,
|
||||
state_key=state_key,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@async_to_sync
|
||||
async def remove_integration(cls, room_id: str, state_key: str):
|
||||
client = await cls._get_client()
|
||||
if room_id.startswith("#"):
|
||||
room_id = await cls.resolve_room_alias(room_id)
|
||||
return await client.room_put_state(
|
||||
room_id=room_id,
|
||||
event_type="im.vector.modular.widgets",
|
||||
content={},
|
||||
state_key=state_key,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@async_to_sync
|
||||
async def kick(cls, room_id: str, user_id: str, reason: str = None):
|
||||
|
Loading…
Reference in New Issue
Block a user