bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/handlers/getUsers.js

36 lines
883 B
JavaScript
Raw Normal View History

import { check } from 'meteor/check';
import { inReplyToHTML5Client } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import addUser from '../modifiers/addUser';
import removeUser from '../modifiers/removeUser';
export default function handleGetUsers({ payload }) {
if (!inReplyToHTML5Client({ payload })) {
return;
}
const meetingId = payload.meeting_id;
const users = payload.users;
check(meetingId, String);
check(users, Array);
2017-02-24 04:26:34 +08:00
const usersIds = users.map(m => m.userid);
const usersToRemove = Users.find({
meetingId,
userId: { $nin: usersIds },
}).fetch();
usersToRemove.forEach(user => removeUser(meetingId, user.userId));
let usersAdded = [];
users.forEach(user => {
usersAdded.push(addUser(meetingId, user));
});
return usersAdded;
};