Add support for moderating rooms. Kick user, mute all users, stop all videos.

This commit is contained in:
Håvar Aambø Fosstveit
2020-03-22 00:43:47 +01:00
parent c70740f5c7
commit 7f2f27b858
15 changed files with 515 additions and 57 deletions
+18
View File
@@ -1,7 +1,10 @@
import * as userRoles from './userRoles';
const initialState =
{
id : null,
picture : null,
roles : [ userRoles.ALL ],
canSendMic : false,
canSendWebcam : false,
canShareScreen : false,
@@ -43,6 +46,21 @@ const me = (state = initialState, action) =>
return { ...state, loggedIn: flag };
}
case 'ADD_ROLE':
{
const roles = [ ...state.roles, action.payload.role ];
return { ...state, roles };
}
case 'REMOVE_ROLE':
{
const roles = state.roles.filter((role) =>
role !== action.payload.role);
return { ...state, roles };
}
case 'SET_PICTURE':
return { ...state, picture: action.payload.picture };
+21
View File
@@ -16,6 +16,9 @@ const peer = (state = {}, action) =>
case 'SET_PEER_SCREEN_IN_PROGRESS':
return { ...state, peerScreenInProgress: action.payload.flag };
case 'SET_PEER_KICK_IN_PROGRESS':
return { ...state, peerKickInProgress: action.payload.flag };
case 'SET_PEER_RAISE_HAND_STATE':
return { ...state, raiseHandState: action.payload.raiseHandState };
@@ -40,6 +43,21 @@ const peer = (state = {}, action) =>
return { ...state, picture: action.payload.picture };
}
case 'ADD_PEER_ROLE':
{
const roles = [ ...state.roles, action.payload.role ];
return { ...state, roles };
}
case 'REMOVE_PEER_ROLE':
{
const roles = state.roles.filter((role) =>
role !== action.payload.role);
return { ...state, roles };
}
default:
return state;
}
@@ -71,6 +89,8 @@ const peers = (state = {}, action) =>
case 'SET_PEER_RAISE_HAND_STATE':
case 'SET_PEER_PICTURE':
case 'ADD_CONSUMER':
case 'ADD_PEER_ROLE':
case 'REMOVE_PEER_ROLE':
{
const oldPeer = state[action.payload.peerId];
@@ -82,6 +102,7 @@ const peers = (state = {}, action) =>
return { ...state, [oldPeer.id]: peer(oldPeer, action) };
}
case 'SET_PEER_KICK_IN_PROGRESS':
case 'REMOVE_CONSUMER':
{
const oldPeer = state[action.payload.peerId];
+6
View File
@@ -163,6 +163,12 @@ const room = (state = initialState, action) =>
return { ...state, spotlights };
}
case 'MUTE_ALL_IN_PROGRESS':
return { ...state, muteAllInProgress: action.payload.flag };
case 'STOP_ALL_VIDEO_IN_PROGRESS':
return { ...state, stopAllVideoInProgress: action.payload.flag };
default:
return state;
}
+4
View File
@@ -0,0 +1,4 @@
export const ADMIN = 'admin';
export const MODERATOR = 'moderator';
export const AUTHENTICATED = 'authenticated';
export const ALL = 'normal';