MODERATE_CHAT role can clear the chat in a room, references issue #209
This commit is contained in:
@@ -229,6 +229,8 @@ module.exports =
|
||||
PROMOTE_PEER : [ userRoles.NORMAL ],
|
||||
// The role(s) have permission to send chat messages
|
||||
SEND_CHAT : [ userRoles.NORMAL ],
|
||||
// The role(s) have permission to moderate chat
|
||||
MODERATE_CHAT : [ userRoles.MODERATOR ],
|
||||
// The role(s) have permission to share screen
|
||||
SHARE_SCREEN : [ userRoles.NORMAL ],
|
||||
// The role(s) have permission to share files
|
||||
|
||||
+22
-16
@@ -1005,6 +1005,24 @@ class Room extends EventEmitter
|
||||
break;
|
||||
}
|
||||
|
||||
case 'moderator:clearChat':
|
||||
{
|
||||
if (
|
||||
!peer.roles.some((role) => config.permissionsFromRoles.MODERATE_CHAT.includes(role))
|
||||
)
|
||||
throw new Error('peer not authorized');
|
||||
|
||||
this._chatHistory = [];
|
||||
|
||||
// Spread to others
|
||||
this._notification(peer.socket, 'moderator:clearChat', null, true);
|
||||
|
||||
// Return no error
|
||||
cb();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'serverHistory':
|
||||
{
|
||||
// Return to sender
|
||||
@@ -1186,9 +1204,7 @@ class Room extends EventEmitter
|
||||
throw new Error('peer not authorized');
|
||||
|
||||
// Spread to others
|
||||
this._notification(peer.socket, 'moderator:mute', {
|
||||
peerId : peer.id
|
||||
}, true);
|
||||
this._notification(peer.socket, 'moderator:mute', null, true);
|
||||
|
||||
cb();
|
||||
|
||||
@@ -1203,9 +1219,7 @@ class Room extends EventEmitter
|
||||
throw new Error('peer not authorized');
|
||||
|
||||
// Spread to others
|
||||
this._notification(peer.socket, 'moderator:stopVideo', {
|
||||
peerId : peer.id
|
||||
}, true);
|
||||
this._notification(peer.socket, 'moderator:stopVideo', null, true);
|
||||
|
||||
cb();
|
||||
|
||||
@@ -1219,12 +1233,7 @@ class Room extends EventEmitter
|
||||
)
|
||||
throw new Error('peer not authorized');
|
||||
|
||||
this._notification(
|
||||
peer.socket,
|
||||
'moderator:kick',
|
||||
null,
|
||||
true
|
||||
);
|
||||
this._notification(peer.socket, 'moderator:kick', null, true);
|
||||
|
||||
cb();
|
||||
|
||||
@@ -1248,10 +1257,7 @@ class Room extends EventEmitter
|
||||
if (!kickPeer)
|
||||
throw new Error(`peer with id "${peerId}" not found`);
|
||||
|
||||
this._notification(
|
||||
kickPeer.socket,
|
||||
'moderator:kick'
|
||||
);
|
||||
this._notification(kickPeer.socket, 'moderator:kick');
|
||||
|
||||
kickPeer.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user