MODERATE_FILES role can clean all files in a room, fixes #209
parent
7340621b6e
commit
e28b6cdc5d
|
|
@ -1317,6 +1317,28 @@ export default class RoomClient
|
|||
roomActions.setClearChatInProgress(false));
|
||||
}
|
||||
|
||||
async clearFileSharing()
|
||||
{
|
||||
logger.debug('clearFileSharing()');
|
||||
|
||||
store.dispatch(
|
||||
roomActions.setClearFileSharingInProgress(true));
|
||||
|
||||
try
|
||||
{
|
||||
await this.sendRequest('moderator:clearFileSharing');
|
||||
|
||||
store.dispatch(fileActions.clearFiles());
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
logger.error('clearFileSharing() failed: %o', error);
|
||||
}
|
||||
|
||||
store.dispatch(
|
||||
roomActions.setClearFileSharingInProgress(false));
|
||||
}
|
||||
|
||||
async kickPeer(peerId)
|
||||
{
|
||||
logger.debug('kickPeer() [peerId:"%s"]', peerId);
|
||||
|
|
@ -2217,6 +2239,21 @@ export default class RoomClient
|
|||
break;
|
||||
}
|
||||
|
||||
case 'moderator:clearFileSharing':
|
||||
{
|
||||
store.dispatch(fileActions.clearFiles());
|
||||
|
||||
store.dispatch(requestActions.notify(
|
||||
{
|
||||
text : intl.formatMessage({
|
||||
id : 'moderator.clearFiles',
|
||||
defaultMessage : 'Moderator cleared the files'
|
||||
})
|
||||
}));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'producerScore':
|
||||
{
|
||||
const { producerId, score } = notification.data;
|
||||
|
|
|
|||
|
|
@ -32,4 +32,9 @@ export const setFileDone = (magnetUri, sharedFiles) =>
|
|||
({
|
||||
type : 'SET_FILE_DONE',
|
||||
payload : { magnetUri, sharedFiles }
|
||||
});
|
||||
|
||||
export const clearFiles = () =>
|
||||
({
|
||||
type : 'CLEAR_FILES'
|
||||
});
|
||||
|
|
@ -135,6 +135,12 @@ export const setClearChatInProgress = (flag) =>
|
|||
payload : { flag }
|
||||
});
|
||||
|
||||
export const setClearFileSharingInProgress = (flag) =>
|
||||
({
|
||||
type : 'CLEAR_FILE_SHARING_IN_PROGRESS',
|
||||
payload : { flag }
|
||||
});
|
||||
|
||||
export const setUserRoles = (userRoles) =>
|
||||
({
|
||||
type : 'SET_USER_ROLES',
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles';
|
|||
import { withRoomContext } from '../../../RoomContext';
|
||||
import { useIntl } from 'react-intl';
|
||||
import FileList from './FileList';
|
||||
import FileSharingModerator from './FileSharingModerator';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import Button from '@material-ui/core/Button';
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ const FileSharing = (props) =>
|
|||
|
||||
return (
|
||||
<Paper className={classes.root}>
|
||||
<FileSharingModerator />
|
||||
<input
|
||||
className={classes.input}
|
||||
type='file'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import { withRoomContext } from '../../../RoomContext';
|
||||
import { withStyles } from '@material-ui/core/styles';
|
||||
import { useIntl, FormattedMessage } from 'react-intl';
|
||||
import Button from '@material-ui/core/Button';
|
||||
|
||||
const styles = (theme) =>
|
||||
({
|
||||
root :
|
||||
{
|
||||
padding : theme.spacing(1),
|
||||
width : '100%',
|
||||
overflow : 'hidden',
|
||||
cursor : 'auto',
|
||||
display : 'flex',
|
||||
listStyleType : 'none',
|
||||
boxShadow : '0 2px 5px 2px rgba(0, 0, 0, 0.2)',
|
||||
backgroundColor : 'rgba(255, 255, 255, 1)'
|
||||
},
|
||||
listheader :
|
||||
{
|
||||
padding : theme.spacing(1),
|
||||
fontWeight : 'bolder'
|
||||
},
|
||||
actionButton :
|
||||
{
|
||||
marginLeft : 'auto'
|
||||
}
|
||||
});
|
||||
|
||||
const FileSharingModerator = (props) =>
|
||||
{
|
||||
const intl = useIntl();
|
||||
|
||||
const {
|
||||
roomClient,
|
||||
isFileSharingModerator,
|
||||
room,
|
||||
classes
|
||||
} = props;
|
||||
|
||||
if (!isFileSharingModerator)
|
||||
return;
|
||||
|
||||
return (
|
||||
<ul className={classes.root}>
|
||||
<li className={classes.listheader}>
|
||||
<FormattedMessage
|
||||
id='room.moderatoractions'
|
||||
defaultMessage='Moderator actions'
|
||||
/>
|
||||
</li>
|
||||
<Button
|
||||
aria-label={intl.formatMessage({
|
||||
id : 'room.clearFileSharing',
|
||||
defaultMessage : 'Clear files'
|
||||
})}
|
||||
className={classes.actionButton}
|
||||
variant='contained'
|
||||
color='secondary'
|
||||
disabled={room.clearFileSharingInProgress}
|
||||
onClick={() => roomClient.clearFileSharing()}
|
||||
>
|
||||
<FormattedMessage
|
||||
id='room.clearFileSharing'
|
||||
defaultMessage='Clear files'
|
||||
/>
|
||||
</Button>
|
||||
</ul>
|
||||
);
|
||||
};
|
||||
|
||||
FileSharingModerator.propTypes =
|
||||
{
|
||||
roomClient : PropTypes.any.isRequired,
|
||||
isFileSharingModerator : PropTypes.bool,
|
||||
room : PropTypes.object,
|
||||
classes : PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) =>
|
||||
({
|
||||
isFileSharingModerator :
|
||||
state.me.roles.some((role) =>
|
||||
state.room.permissionsFromRoles.MODERATE_FILES.includes(role)),
|
||||
room : state.room
|
||||
});
|
||||
|
||||
export default withRoomContext(connect(
|
||||
mapStateToProps,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
areStatesEqual : (next, prev) =>
|
||||
{
|
||||
return (
|
||||
prev.room === next.room &&
|
||||
prev.me === next.me
|
||||
);
|
||||
}
|
||||
}
|
||||
)(withStyles(styles)(FileSharingModerator)));
|
||||
|
|
@ -85,6 +85,9 @@ const files = (state = {}, action) =>
|
|||
return { ...state, [magnetUri]: newFile };
|
||||
}
|
||||
|
||||
case 'CLEAR_FILES':
|
||||
return {};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,38 @@
|
|||
const initialState =
|
||||
{
|
||||
name : '',
|
||||
state : 'new', // new/connecting/connected/disconnected/closed,
|
||||
locked : false,
|
||||
inLobby : false,
|
||||
signInRequired : false,
|
||||
accessCode : '', // access code to the room if locked and joinByAccessCode == true
|
||||
joinByAccessCode : true, // if true: accessCode is a possibility to open the room
|
||||
activeSpeakerId : null,
|
||||
torrentSupport : false,
|
||||
showSettings : false,
|
||||
fullScreenConsumer : null, // ConsumerID
|
||||
windowConsumer : null, // ConsumerID
|
||||
toolbarsVisible : true,
|
||||
mode : 'democratic',
|
||||
selectedPeerId : null,
|
||||
spotlights : [],
|
||||
settingsOpen : false,
|
||||
lockDialogOpen : false,
|
||||
joined : false,
|
||||
muteAllInProgress : false,
|
||||
stopAllVideoInProgress : false,
|
||||
closeMeetingInProgress : false,
|
||||
clearChatInProgress : false,
|
||||
userRoles : { NORMAL: 'normal' }, // Default role
|
||||
permissionsFromRoles : {
|
||||
name : '',
|
||||
state : 'new', // new/connecting/connected/disconnected/closed,
|
||||
locked : false,
|
||||
inLobby : false,
|
||||
signInRequired : false,
|
||||
accessCode : '', // access code to the room if locked and joinByAccessCode == true
|
||||
joinByAccessCode : true, // if true: accessCode is a possibility to open the room
|
||||
activeSpeakerId : null,
|
||||
torrentSupport : false,
|
||||
showSettings : false,
|
||||
fullScreenConsumer : null, // ConsumerID
|
||||
windowConsumer : null, // ConsumerID
|
||||
toolbarsVisible : true,
|
||||
mode : 'democratic',
|
||||
selectedPeerId : null,
|
||||
spotlights : [],
|
||||
settingsOpen : false,
|
||||
lockDialogOpen : false,
|
||||
joined : false,
|
||||
muteAllInProgress : false,
|
||||
stopAllVideoInProgress : false,
|
||||
closeMeetingInProgress : false,
|
||||
clearChatInProgress : false,
|
||||
clearFileSharingInProgress : false,
|
||||
userRoles : { NORMAL: 'normal' }, // Default role
|
||||
permissionsFromRoles : {
|
||||
CHANGE_ROOM_LOCK : [],
|
||||
PROMOTE_PEER : [],
|
||||
SEND_CHAT : [],
|
||||
MODERATE_CHAT : [],
|
||||
SHARE_SCREEN : [],
|
||||
SHARE_FILE : [],
|
||||
MODERATE_FILES : [],
|
||||
MODERATE_ROOM : []
|
||||
}
|
||||
};
|
||||
|
|
@ -189,6 +191,9 @@ const room = (state = initialState, action) =>
|
|||
case 'CLEAR_CHAT_IN_PROGRESS':
|
||||
return { ...state, clearChatInProgress: action.payload.flag };
|
||||
|
||||
case 'CLEAR_FILE_SHARING_IN_PROGRESS':
|
||||
return { ...state, clearFileSharingInProgress: action.payload.flag };
|
||||
|
||||
case 'SET_USER_ROLES':
|
||||
{
|
||||
const { userRoles } = action.payload;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "访问相机时发生错误",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
@ -52,6 +52,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -142,6 +143,7 @@
|
|||
"devices.cameraError": "Při přístupu k vaší kameře se vyskytla chyba",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": "Alle Videos stoppen",
|
||||
"room.closeMeeting": "Meeting schließen",
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": "Dein Browser unterstützt keine Spracherkennung",
|
||||
|
||||
"me.mutedPTT": "Du bist stummgeschalted, Halte die SPACE-Taste um zu sprechen",
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Fehler mit deiner Kamera",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"device.cameraError": "Der opstod en fejl ved tilkobling af dit kamera",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Παρουσιάστηκε σφάλμα κατά την πρόσβαση στην κάμερά σας",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": "Stop all video",
|
||||
"room.closeMeeting": "Close meeting",
|
||||
"room.clearChat": "Clear chat",
|
||||
"room.clearFileSharing": "Clear files",
|
||||
"room.speechUnsupported": "Your browser does not support speech recognition",
|
||||
|
||||
"me.mutedPTT": "You are muted, hold down SPACE-BAR to talk",
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "An error occured while accessing your camera",
|
||||
|
||||
"moderator.clearChat": "Moderator cleared the chat",
|
||||
"moderator.clearFiles": "Moderator cleared the files",
|
||||
"moderator.muteAudio": "Moderator muted your audio",
|
||||
"moderator.muteVideo": "Moderator muted your video"
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Hubo un error al acceder a su cámara",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -146,6 +147,7 @@
|
|||
"devices.cameraError": "Une erreur est apparue lors de l'accès à votre caméra",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": "Ugasi sve kamere",
|
||||
"room.closeMeeting": "Završi sastanak",
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": "Vaš preglednik ne podržava prepoznavanje govora",
|
||||
|
||||
"me.mutedPTT": "Utišani ste, pritisnite i držite SPACE tipku za razgovor",
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Greška prilikom pristupa kameri",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Hiba történt a kamera elérése során",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -146,6 +147,7 @@
|
|||
"devices.cameraError": "Errore con l'accesso alla videocamera",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": "Stopp all video",
|
||||
"room.closeMeeting": "Avslutt møte",
|
||||
"room.clearChat": "Tøm chat",
|
||||
"room.clearFileSharing": "Fjern filer",
|
||||
"room.speechUnsupported": "Din nettleser støtter ikke stemmegjenkjenning",
|
||||
|
||||
"me.mutedPTT": "Du er dempet, hold nede SPACE for å snakke",
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Det skjedde noe feil med kameraet ditt",
|
||||
|
||||
"moderator.clearChat": "Moderator tømte chatten",
|
||||
"moderator.clearFiles": "Moderator fjernet filer",
|
||||
"moderator.muteAudio": "Moderator mutet lyden din",
|
||||
"moderator.muteVideo": "Moderator mutet videoen din"
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Wystąpił błąd podczas uzyskiwania dostępu do kamery",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "Ocorreu um erro no acesso à sua câmara",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"me.mutedPTT": null,
|
||||
|
|
@ -147,6 +148,7 @@
|
|||
"devices.cameraError": "A apărut o eroare la accesarea camerei video",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
"room.stopAllVideo": null,
|
||||
"room.closeMeeting": null,
|
||||
"room.clearChat": null,
|
||||
"room.clearFileSharing": null,
|
||||
"room.speechUnsupported": null,
|
||||
|
||||
"tooltip.login": "Увійти",
|
||||
|
|
@ -144,6 +145,7 @@
|
|||
"devices.cameraError": "Під час доступу до камери сталася помилка",
|
||||
|
||||
"moderator.clearChat": null,
|
||||
"moderator.clearFiles": null,
|
||||
"moderator.muteAudio": null,
|
||||
"moderator.muteVideo": null
|
||||
}
|
||||
|
|
@ -235,6 +235,8 @@ module.exports =
|
|||
SHARE_SCREEN : [ userRoles.NORMAL ],
|
||||
// The role(s) have permission to share files
|
||||
SHARE_FILE : [ userRoles.NORMAL ],
|
||||
// The role(s) have permission to moderate files
|
||||
MODERATE_FILES : [ userRoles.MODERATOR ],
|
||||
// The role(s) have permission to moderate room (e.g. kick user)
|
||||
MODERATE_ROOM : [ userRoles.MODERATOR ]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1178,6 +1178,24 @@ class Room extends EventEmitter
|
|||
break;
|
||||
}
|
||||
|
||||
case 'moderator:clearFileSharing':
|
||||
{
|
||||
if (
|
||||
!peer.roles.some((role) => config.permissionsFromRoles.MODERATE_FILES.includes(role))
|
||||
)
|
||||
throw new Error('peer not authorized');
|
||||
|
||||
this._fileHistory = [];
|
||||
|
||||
// Spread to others
|
||||
this._notification(peer.socket, 'moderator:clearFileSharing', null, true);
|
||||
|
||||
// Return no error
|
||||
cb();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'raiseHand':
|
||||
{
|
||||
const { raisedHand } = request.data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue