MODERATE_CHAT role can clear the chat in a room, references issue #209

This commit is contained in:
Håvar Aambø Fosstveit
2020-04-20 23:22:19 +02:00
parent df86c8b493
commit 91a258c273
25 changed files with 417 additions and 161 deletions
+2
View File
@@ -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
View File
@@ -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();