bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/muteUser.js

43 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-06-02 01:18:13 +08:00
import { publish } from '/imports/api/common/server/helpers';
import { isAllowedTo } from '/imports/startup/server/userPermissions';
2016-06-02 01:18:13 +08:00
import { appendMessageHeader } from '/imports/api/common/server/helpers';
2016-05-16 22:35:59 +08:00
import { updateVoiceUser } from '/imports/api/users/server/modifiers/updateVoiceUser';
2016-05-05 02:29:43 +08:00
import { logger } from '/imports/startup/server/logger';
2016-04-20 01:43:31 +08:00
Meteor.methods({
// meetingId: the meetingId of the meeting the user[s] is in
// toMuteUserId: the userId of the user to be muted
// requesterUserId: the userId of the requester
// requesterToken: the authToken of the requester
2016-05-17 02:12:27 +08:00
muteUser(credentials, toMuteUserId) {
const REDIS_CONFIG = Meteor.settings.redis;
2016-05-17 02:12:27 +08:00
const { meetingId, requesterUserId, requesterToken } = credentials;
2016-05-16 22:35:59 +08:00
const action = function () {
2016-04-20 01:43:31 +08:00
if (toMuteUserId === requesterUserId) {
return 'muteSelf';
} else {
return 'muteOther';
}
};
if (isAllowedTo(action(), credentials)) {
2016-05-16 22:35:59 +08:00
let message = {
2016-04-20 01:43:31 +08:00
payload: {
user_id: toMuteUserId,
meeting_id: meetingId,
mute: true,
requester_id: requesterUserId,
2016-05-05 05:49:01 +08:00
},
2016-04-20 01:43:31 +08:00
};
2016-04-20 05:16:32 +08:00
message = appendMessageHeader('mute_user_request_message', message);
2016-04-29 05:37:15 +08:00
logger.info(`publishing a user mute request for ${toMuteUserId}`);
publish(REDIS_CONFIG.channels.toBBBApps.users, message);
2016-04-20 01:43:31 +08:00
updateVoiceUser(meetingId, {
web_userid: toMuteUserId,
talking: false,
muted: true,
});
}
2016-05-05 05:49:01 +08:00
},
2016-04-20 01:43:31 +08:00
});