2017-06-19 21:13:35 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-06-29 02:14:29 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
2017-06-19 21:13:35 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-08-01 23:00:07 +08:00
|
|
|
import removeVoiceUser from '/imports/api/2.0/voice-users/server/modifiers/removeVoiceUser';
|
2017-06-19 21:13:35 +08:00
|
|
|
|
|
|
|
const CLIENT_TYPE_HTML = 'HTML5';
|
|
|
|
|
|
|
|
export default function removeUser(meetingId, userId) {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
'user.connection_status': 'offline',
|
|
|
|
'user.time_of_joining': 0,
|
|
|
|
'user.validated': false,
|
2017-07-13 21:15:42 +08:00
|
|
|
'user.emoji': 'none',
|
2017-06-19 21:13:35 +08:00
|
|
|
'user.presenter': false,
|
|
|
|
'user.role': 'VIEWER',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-08-01 23:00:07 +08:00
|
|
|
removeVoiceUser(meetingId, {
|
|
|
|
voiceConf: '',
|
|
|
|
voiceUserId: '',
|
|
|
|
intId: userId,
|
|
|
|
});
|
|
|
|
|
2017-08-01 21:10:12 +08:00
|
|
|
const cb = (err) => {
|
2017-06-19 21:13:35 +08:00
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Removing user from collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
2017-08-01 21:10:12 +08:00
|
|
|
return Logger.info(`Removed ${CLIENT_TYPE_HTML} user id=${userId} meeting=${meetingId}`);
|
2017-06-19 21:13:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return Users.update(selector, modifier, cb);
|
|
|
|
}
|