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
|
|
|
|
|
|
|
|
2018-04-10 07:18:49 +08:00
|
|
|
export default 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);
|
|
|
|
check(multiUser, Boolean);
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Error while adding an entry to Multi-User collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const { insertedId } = numChanged;
|
|
|
|
if (insertedId) {
|
2018-04-11 07:49:56 +08:00
|
|
|
return Logger.info(`Added multiUser flag=${multiUser} meetingId=${meetingId} whiteboardId=${whiteboardId}`);
|
2017-08-03 09:24:38 +08:00
|
|
|
}
|
|
|
|
|
2018-04-11 07:49:56 +08:00
|
|
|
return Logger.info(`Upserted multiUser flag=${multiUser} meetingId=${meetingId} whiteboardId=${whiteboardId}`);
|
2017-08-03 09:24:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return WhiteboardMultiUser.upsert(selector, modifier, cb);
|
|
|
|
}
|