bigbluebutton-Github/bigbluebutton-html5/imports/api/annotations/server/methods/clearWhiteboard.js

30 lines
1.0 KiB
JavaScript
Raw Normal View History

import Acl from '/imports/startup/acl';
import { getMultiUserStatus } from '/imports/api/common/server/helpers';
import RedisPubSub from '/imports/startup/server/redis';
2017-04-22 02:01:52 +08:00
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
export default function clearWhiteboard(credentials, whiteboardId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'ClearWhiteboardPubMsg';
2017-04-22 02:01:52 +08:00
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
check(whiteboardId, String);
2017-04-22 02:01:52 +08:00
2018-04-10 07:18:49 +08:00
const allowed = Acl.can('methods.clearWhiteboard', credentials) || getMultiUserStatus(meetingId, whiteboardId);
if (!allowed) {
2018-01-08 08:25:56 +08:00
throw new Meteor.Error('not-allowed', `User ${requesterUserId} is not allowed to clear the whiteboard`);
}
const payload = {
whiteboardId,
2017-04-22 02:01:52 +08:00
};
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
2017-04-22 02:01:52 +08:00
}