bigbluebutton-Github/bigbluebutton-html5/imports/api/guest-users/server/methods/allowPendingUsers.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'GuestsWaitingApprovedMsg';
export default function allowPendingUsers(guests, status) {
2021-05-05 20:26:21 +08:00
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
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 }));
2021-05-05 20:26:21 +08:00
const payload = {
approvedBy: requesterUserId,
guests: mappedGuests,
};
2021-05-05 20:26:21 +08:00
Logger.info(`User=${requesterUserId} ${status} guests ${JSON.stringify(mappedGuests)}`);
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}`);
}
}