bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/modifiers/requestUserLeaving.js
Anton Georgiev 8d52dc1b40 Merge branch 'join-components-with-skeleton' of github.com:perroned/bigbluebutton into router-merging
Conflicts:
	bigbluebutton-html5/imports/api/chat/server/methods/sendChatMessagetoServer.js
	bigbluebutton-html5/imports/api/meetings/server/modifiers/addMeetingToCollection.js
	bigbluebutton-html5/imports/api/polls/server/methods/publishVoteMessage.js
	bigbluebutton-html5/imports/api/slides/server/modifiers/clearSlidesCollection.js
	bigbluebutton-html5/imports/api/users/server/methods/muteUser.js
	bigbluebutton-html5/imports/api/users/server/methods/setUserPresenter.js
	bigbluebutton-html5/imports/api/users/server/methods/unmuteUser.js
	bigbluebutton-html5/imports/api/users/server/methods/userSetEmoji.js
	bigbluebutton-html5/imports/api/users/server/methods/validateAuthToken.js
	bigbluebutton-html5/imports/startup/server/eventHandlers.js
	bigbluebutton-html5/imports/ui/components/app/AppService.js
2016-05-16 19:54:51 +00:00

63 lines
2.0 KiB
JavaScript
Executable File

import { publish } from '/imports/startup/server/helpers';
import Meetings from '/imports/api/meetings';
import Users from '/imports/api/users';
import { logger } from '/imports/startup/server/logger';
import { redisConfig } from '/config';
// Corresponds to a valid action on the HTML clientside
// After authorization, publish a user_leaving_request in redis
// params: meetingid, userid as defined in BBB-App
export function requestUserLeaving(meetingId, userId) {
let listenOnlyMessage, message, userObject, meetingObject, voiceConf;
userObject = Users.findOne({
meetingId: meetingId,
userId: userId,
});
meetingObject = Meetings.findOne({
meetingId: meetingId,
});
if (meetingObject != null) {
voiceConf = meetingObject.voiceConf;
}
if ((userObject != null) && (voiceConf != null) && (userId != null) && (meetingId != null)) {
let lOnly = false;
if (userObject.hasOwnProperty('user') && userObject.user.hasOwnProperty('listenOnly')) {
lOnly = userObject.user.listenOnly;
}
// end listenOnly audio for the departing user
if (null != lOnly && lOnly) {
listenOnlyMessage = {
payload: {
userid: userId,
meeting_id: meetingId,
voice_conf: voiceConf,
name: userObject.user.name,
},
header: {
timestamp: new Date().getTime(),
name: 'user_disconnected_from_global_audio',
},
};
publish(redisConfig.channels.toBBBApps.meeting, listenOnlyMessage);
}
// remove user from meeting
message = {
payload: {
meeting_id: meetingId,
userid: userId,
},
header: {
timestamp: new Date().getTime(),
name: 'user_leaving_request',
},
};
logger.info(`sending a user_leaving_request for ${meetingId}:${userId}`);
return publish(redisConfig.channels.toBBBApps.users, message);
} else {
return logger.info('did not have enough information to send a user_leaving_request');
}
};