diff --git a/bigbluebutton-html5/imports/api/2.0/users/server/eventHandlers.js b/bigbluebutton-html5/imports/api/2.0/users/server/eventHandlers.js index 8af0a56bea..4d1810b7b0 100644 --- a/bigbluebutton-html5/imports/api/2.0/users/server/eventHandlers.js +++ b/bigbluebutton-html5/imports/api/2.0/users/server/eventHandlers.js @@ -7,6 +7,7 @@ import handleEmojiStatus from './handlers/emojiStatus'; import handleGetUsers from './handlers/getUsers'; import handleGuestsWaitingForApproval from './handlers/guestsWaitingForApproval'; import handleGuestApproved from './handlers/guestApproved'; +import handleKickUser from './handlers/kickUser'; RedisPubSub.on('PresenterAssignedEvtMsg', handlePresenterAssigned); RedisPubSub.on('UserJoinedMeetingEvtMsg', handleUserJoined); @@ -16,3 +17,4 @@ RedisPubSub.on('UserEmojiChangedEvtMsg', handleEmojiStatus); RedisPubSub.on('SyncGetUsersMeetingRespMsg', handleGetUsers); RedisPubSub.on('GuestsWaitingForApprovalEvtMsg', handleGuestsWaitingForApproval); RedisPubSub.on('GuestApprovedEvtMsg', handleGuestApproved); +RedisPubSub.on('UserEjectedFromMeetingEvtMsg', handleKickUser); diff --git a/bigbluebutton-html5/imports/api/2.0/users/server/handlers/kickUser.js b/bigbluebutton-html5/imports/api/2.0/users/server/handlers/kickUser.js new file mode 100644 index 0000000000..23eb234931 --- /dev/null +++ b/bigbluebutton-html5/imports/api/2.0/users/server/handlers/kickUser.js @@ -0,0 +1,8 @@ +import kickUser from '../modifiers/kickUser'; + +export default function handleKickUser({ header }) { + const meetingId = header.meetingId; + const userId = header.userId; + + return kickUser(meetingId, userId); +} diff --git a/bigbluebutton-html5/imports/api/2.0/users/server/modifiers/kickUser.js b/bigbluebutton-html5/imports/api/2.0/users/server/modifiers/kickUser.js new file mode 100644 index 0000000000..9bb15ce77b --- /dev/null +++ b/bigbluebutton-html5/imports/api/2.0/users/server/modifiers/kickUser.js @@ -0,0 +1,39 @@ +import { check } from 'meteor/check'; +import Logger from '/imports/startup/server/logger'; +import Users from './../../'; + +export default function kickUser(meetingId, userId) { + check(meetingId, String); + check(userId, String); + + const selector = { + meetingId, + userId, + }; + + const modifier = { + $set: { + 'user.kicked': true, + 'user.connection_status': 'offline', + 'user.voiceUser.talking': false, + 'user.voiceUser.joined': false, + 'user.voiceUser.muted': false, + 'user.time_of_joining': 0, + 'user.listenOnly': false, + }, + }; + + const cb = (err, numChanged) => { + if (err) { + return Logger.error(`Kicking user from collection: ${err}`); + } + + if (numChanged) { + return Logger.info(`Kicked user id=${userId} meeting=${meetingId}`); + } + + return null; + }; + + return Users.update(selector, modifier, cb); +}