Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Check whether commands are coming from moderator.

damenchoaf9f651702c6
diff --git a/conference.js b/conference.js
index a59cfd429b..d483884227 100644
--- a/conference.js
+++ b/conference.js
@@ -402,6 +402,15 @@ export default {
listMembersIds () {
return room.getParticipants().map(p => p.getId());
},
+ /**
+ * Checks whether the participant identified by id is a moderator.
+ * @id id to search for participant
+ * @return {boolean} whether the participant is moderator
+ */
+ isParticipantModerator (id) {
+ let user = room.getParticipantById(id);
+ return user && user.isModerator();
+ },
/**
* Check if SIP is supported.
* @returns {boolean}
@@ -737,7 +746,7 @@ export default {
console.log('USER %s LEFT', id, user);
APP.API.notifyUserLeft(id);
APP.UI.removeUser(id, user.getDisplayName());
- APP.UI.stopSharedVideo({from: id});
+ APP.UI.stopSharedVideo(id);
});
@@ -1083,7 +1092,6 @@ export default {
room.sendCommandOnce(Commands.SHARED_VIDEO, {
value: url,
attributes: {
- from: APP.conference.localId,
state: state,
time: time,
volume: volume
@@ -1096,7 +1104,6 @@ export default {
room.sendCommand(Commands.SHARED_VIDEO, {
value: url,
attributes: {
- from: APP.conference.localId,
state: state,
time: time,
volume: volume
@@ -1105,14 +1112,25 @@ export default {
}
});
room.addCommandListener(
- Commands.SHARED_VIDEO, ({value, attributes}) => {
+ Commands.SHARED_VIDEO, ({value, attributes}, id) => {
+
+ // if we are not the moderator or
+ // the command is coming from a user which is not the moderator
+ if (!(this.isLocalId(id) && room.isModerator())
+ && !this.isParticipantModerator(id))
+ {
+ console.warn('Received shared video command ' +
+ 'not from moderator');
+ return;
+ }
+
if (attributes.state === 'stop') {
- APP.UI.stopSharedVideo(attributes);
+ APP.UI.stopSharedVideo(id, attributes);
} else if (attributes.state === 'start') {
- APP.UI.showSharedVideo(value, attributes);
+ APP.UI.showSharedVideo(id, value, attributes);
} else if (attributes.state === 'playing'
|| attributes.state === 'pause') {
- APP.UI.updateSharedVideo(value, attributes);
+ APP.UI.updateSharedVideo(id, value, attributes);
}
});
}
diff --git a/modules/FollowMe.js b/modules/FollowMe.js
index dd9bd39261..e7401ecc0f 100644
--- a/modules/FollowMe.js
+++ b/modules/FollowMe.js
@@ -270,7 +270,12 @@ class FollowMe {
if (this._conference.isLocalId(id))
return;
- // TODO Don't obey commands issued by non-moderators.
+ if (!this._conference.isParticipantModerator(id))
+ {
+ console.warn('Received follow-me command ' +
+ 'not from moderator');
+ return;
+ }
// Applies the received/remote command to the user experience/interface
// of the local participant.
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index a914e1d24a..c0fad8f891 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -1107,32 +1107,35 @@ UI.updateDevicesAvailability = function (id, devices) {
};
/**
-* Show shared video.
-* @param {string} url video url
-* @param {string} attributes
+ * Show shared video.
+ * @param {string} id the id of the sender of the command
+ * @param {string} url video url
+ * @param {string} attributes
*/
-UI.showSharedVideo = function (url, attributes) {
+UI.showSharedVideo = function (id, url, attributes) {
if (sharedVideoManager)
- sharedVideoManager.showSharedVideo(url, attributes);
+ sharedVideoManager.showSharedVideo(id, url, attributes);
};
/**
* Update shared video.
+ * @param {string} id the id of the sender of the command
* @param {string} url video url
* @param {string} attributes
*/
-UI.updateSharedVideo = function (url, attributes) {
+UI.updateSharedVideo = function (id, url, attributes) {
if (sharedVideoManager)
- sharedVideoManager.updateSharedVideo(url, attributes);
+ sharedVideoManager.updateSharedVideo(id, url, attributes);
};
/**
* Stop showing shared video.
+ * @param {string} id the id of the sender of the command
* @param {string} attributes
*/
-UI.stopSharedVideo = function (attributes) {
+UI.stopSharedVideo = function (id, attributes) {
if (sharedVideoManager)
- sharedVideoManager.stopSharedVideo(attributes);
+ sharedVideoManager.stopSharedVideo(id, attributes);
};
module.exports = UI;
diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js
index d76c2a3a82..f769a1f59c 100644
--- a/modules/UI/shared_video/SharedVideo.js
+++ b/modules/UI/shared_video/SharedVideo.js
@@ -50,10 +50,11 @@ export default class SharedVideoManager {
/**
* Shows the player component and starts the checking function
* that will be sending updates, if we are the one shared the video
+ * @param id the id of the sender of the command
* @param url the video url
* @param attributes
*/
- showSharedVideo (url, attributes) {
+ showSharedVideo (id, url, attributes) {
if (this.isSharedVideoShown)
return;
@@ -61,7 +62,7 @@ export default class SharedVideoManager {
this.url = url;
// the owner of the video
- this.from = attributes.from;
+ this.from = id;
// This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
@@ -184,10 +185,11 @@ export default class SharedVideoManager {
/**
* Updates video, if its not playing and needs starting or
* if its playing and needs to be paysed
+ * @param id the id of the sender of the command
* @param url the video url
* @param attributes
*/
- updateSharedVideo (url, attributes) {
+ updateSharedVideo (id, url, attributes) {
// if we are sending the event ignore
if(APP.conference.isLocalId(this.from)) {
return;
@@ -196,7 +198,7 @@ export default class SharedVideoManager {
if (attributes.state == 'playing') {
if(!this.isSharedVideoShown) {
- this.showSharedVideo(url, attributes);
+ this.showSharedVideo(id, url, attributes);
return;
}
@@ -239,22 +241,23 @@ export default class SharedVideoManager {
else {
// if not shown show it, passing attributes so it can
// be shown paused
- this.showSharedVideo(url, attributes);
+ this.showSharedVideo(id, url, attributes);
}
}
}
/**
* Stop shared video if it is currently showed. If the user started the
- * shared video is the one in the attributes.from (called when user
+ * shared video is the one in the id (called when user
* left and we want to remove video if the user sharing it left).
+ * @param id the id of the sender of the command
* @param attributes
*/
- stopSharedVideo (attributes) {
+ stopSharedVideo (id, attributes) {
if (!this.isSharedVideoShown)
return;
- if(this.from !== attributes.from)
+ if(this.from !== id)
return;
if(this.intervalId) {