Moderator: Mute or stop video for a peer globally (#316)

This commit is contained in:
L4ky
2020-05-08 00:23:16 +02:00
committed by GitHub
parent 837aa1ace2
commit 2eab32cafa
5 changed files with 168 additions and 0 deletions
+46
View File
@@ -1369,6 +1369,29 @@ class Room extends EventEmitter
break;
}
case 'moderator:mute':
{
if (
!peer.roles.some(
(role) => permissionsFromRoles.MODERATE_ROOM.includes(role)
)
)
throw new Error('peer not authorized');
const { peerId } = request.data;
const mutePeer = this._peers[peerId];
if (!mutePeer)
throw new Error(`peer with id "${peerId}" not found`);
this._notification(mutePeer.socket, 'moderator:mute');
cb();
break;
}
case 'moderator:muteAll':
{
if (
@@ -1386,6 +1409,29 @@ class Room extends EventEmitter
break;
}
case 'moderator:stopVideo':
{
if (
!peer.roles.some(
(role) => permissionsFromRoles.MODERATE_ROOM.includes(role)
)
)
throw new Error('peer not authorized');
const { peerId } = request.data;
const stopVideoPeer = this._peers[peerId];
if (!stopVideoPeer)
throw new Error(`peer with id "${peerId}" not found`);
this._notification(stopVideoPeer.socket, 'moderator:stopVideo');
cb();
break;
}
case 'moderator:stopAllVideo':
{
if (