bigbluebutton-Github/bigbluebutton-html5/imports/api/meetings/server/methods/endMeeting.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-09-07 03:36:52 +08:00
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
2017-09-07 03:36:52 +08:00
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
2017-09-07 03:36:52 +08:00
export default function endMeeting(credentials) {
const REDIS_CONFIG = Meteor.settings.private.redis;
2017-09-07 03:36:52 +08:00
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'LogoutAndEndMeetingCmdMsg';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
2017-09-07 03:36:52 +08:00
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
const selector = {
meetingId,
2017-09-07 03:36:52 +08:00
userId: requesterUserId,
};
const user = Users.findOne(selector);
2017-09-07 03:36:52 +08:00
if (!!user && user.role === ROLE_MODERATOR) {
const payload = {
userId: requesterUserId,
};
2017-09-07 03:36:52 +08:00
Logger.verbose(`Meeting '${meetingId}' is destroyed by '${requesterUserId}'`);
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
}
2017-09-07 03:36:52 +08:00
}