2017-08-03 09:24:38 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import WhiteboardMultiUser from '/imports/api/whiteboard-multi-user/';
|
2017-08-03 09:24:38 +08:00
|
|
|
|
2023-03-09 01:36:40 +08:00
|
|
|
export default async function modifyWhiteboardAccess(meetingId, whiteboardId, multiUser) {
|
2017-08-03 09:24:38 +08:00
|
|
|
check(meetingId, String);
|
2018-04-10 07:18:49 +08:00
|
|
|
check(whiteboardId, String);
|
2021-03-05 06:26:25 +08:00
|
|
|
check(multiUser, Array);
|
2017-08-03 09:24:38 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
2018-04-10 07:18:49 +08:00
|
|
|
whiteboardId,
|
2017-08-03 09:24:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
2018-04-10 07:18:49 +08:00
|
|
|
meetingId,
|
|
|
|
whiteboardId,
|
|
|
|
multiUser,
|
2017-08-03 09:24:38 +08:00
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
2023-03-09 01:36:40 +08:00
|
|
|
const { insertedId } = await WhiteboardMultiUser.upsertAsync(selector, modifier);
|
2017-08-03 09:24:38 +08:00
|
|
|
if (insertedId) {
|
2020-11-23 21:13:46 +08:00
|
|
|
Logger.info(`Added multiUser flag=${multiUser} meetingId=${meetingId} whiteboardId=${whiteboardId}`);
|
|
|
|
} else {
|
|
|
|
Logger.info(`Upserted multiUser flag=${multiUser} meetingId=${meetingId} whiteboardId=${whiteboardId}`);
|
2017-08-03 09:24:38 +08:00
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error while adding an entry to Multi-User collection: ${err}`);
|
|
|
|
}
|
2017-08-03 09:24:38 +08:00
|
|
|
}
|