2017-02-23 02:59:47 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-03-08 01:32:24 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-02-23 02:59:47 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
|
|
|
import setConnectionStatus from './setConnectionStatus';
|
|
|
|
|
|
|
|
const CLIENT_TYPE_HTML = 'HTML5';
|
|
|
|
|
|
|
|
export default function removeUser(meetingId, userId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const User = Users.findOne(selector);
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
'user.connection_status': 'offline',
|
|
|
|
'user.voiceUser.talking': false,
|
|
|
|
'user.voiceUser.joined': false,
|
|
|
|
'user.voiceUser.muted': false,
|
|
|
|
'user.time_of_joining': 0,
|
2017-02-24 04:16:10 +08:00
|
|
|
'user.listenOnly': false,
|
2017-04-20 01:11:13 +08:00
|
|
|
'user.validated': false,
|
|
|
|
'user.emoji_status': 'none',
|
|
|
|
'user.presenter': false,
|
|
|
|
'user.role': "VIEWER",
|
2017-02-23 02:59:47 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Removing user from collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
|
|
|
return Logger.info(`Removed ${CLIENT_TYPE_HTML} user id=${userId} meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return Users.update(selector, modifier, cb);
|
|
|
|
};
|