2017-07-14 22:18:07 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-08-01 02:48:56 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
2017-07-14 22:18:07 +08:00
|
|
|
import setApprovedStatus from '../modifiers/setApprovedStatus';
|
2017-08-01 02:48:56 +08:00
|
|
|
import userJoin from '../methods/userJoin';
|
2017-07-14 22:18:07 +08:00
|
|
|
|
|
|
|
export default function handleGuestsWaitingForApproval({ header, body }, meetingId) {
|
|
|
|
const { userId } = header;
|
|
|
|
const { approved, approvedBy } = body;
|
|
|
|
|
|
|
|
check(userId, String);
|
|
|
|
check(meetingId, String);
|
|
|
|
check(approved, Boolean);
|
|
|
|
check(approvedBy, String);
|
|
|
|
|
2017-08-01 02:48:56 +08:00
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const User = Users.findOne(selector);
|
|
|
|
|
|
|
|
if (User && approved) {
|
|
|
|
userJoin(meetingId, userId, User.authToken);
|
|
|
|
}
|
|
|
|
|
2017-07-14 22:18:07 +08:00
|
|
|
return setApprovedStatus(meetingId, userId, approved, approvedBy);
|
|
|
|
}
|