2019-02-27 01:08:15 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2019-02-27 01:08:15 +08:00
|
|
|
|
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'GuestsWaitingApprovedMsg';
|
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function allowPendingUsers(guests, status) {
|
2021-05-05 20:26:21 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-02-27 01:08:15 +08:00
|
|
|
|
2021-05-05 20:26:21 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(guests, Array);
|
|
|
|
const mappedGuests = guests.map((guest) => ({ status, guest: guest.intId }));
|
2019-02-27 01:08:15 +08:00
|
|
|
|
2021-05-05 20:26:21 +08:00
|
|
|
const payload = {
|
|
|
|
approvedBy: requesterUserId,
|
|
|
|
guests: mappedGuests,
|
|
|
|
};
|
2019-02-27 01:08:15 +08:00
|
|
|
|
2021-05-05 20:26:21 +08:00
|
|
|
Logger.info(`User=${requesterUserId} ${status} guests ${JSON.stringify(mappedGuests)}`);
|
2019-02-27 01:08:15 +08:00
|
|
|
|
2021-05-05 20:26:21 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method allowPendingUsers ${err.stack}`);
|
|
|
|
}
|
2019-02-27 01:08:15 +08:00
|
|
|
}
|