2020-02-04 04:41:12 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
export default async function setGuestPolicy(meetingId, guestPolicy) {
|
2020-02-04 04:41:12 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(guestPolicy, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2020-03-05 04:20:10 +08:00
|
|
|
'usersProp.guestPolicy': guestPolicy,
|
2020-02-04 04:41:12 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-03-12 20:22:08 +08:00
|
|
|
try {
|
2023-03-14 00:59:52 +08:00
|
|
|
const { numberAffected } = await Meetings.upsertAsync(selector, modifier);
|
2020-02-04 04:41:12 +08:00
|
|
|
|
2021-03-12 20:22:08 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.verbose(`Set guest policy meetingId=${meetingId} guestPolicy=${guestPolicy}`);
|
2020-02-04 04:41:12 +08:00
|
|
|
}
|
2021-03-12 20:22:08 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Setting guest policy: ${err}`);
|
|
|
|
}
|
2020-02-04 04:41:12 +08:00
|
|
|
}
|