2021-10-16 03:07:13 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Pads from '/imports/api/pads';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
|
|
|
export default function createPad(meetingId, externalId, padId) {
|
|
|
|
try {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(externalId, String);
|
|
|
|
check(padId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
externalId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
padId,
|
2022-10-24 21:11:28 +08:00
|
|
|
pinned: false,
|
2021-10-16 03:07:13 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const { insertedId } = Pads.upsert(selector, modifier);
|
|
|
|
|
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Added pad=${padId} external=${externalId} meeting=${meetingId}`);
|
|
|
|
} else {
|
|
|
|
Logger.info(`Upserted pad=${padId} external=${externalId} meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Adding pad to the collection: ${err}`);
|
|
|
|
}
|
|
|
|
}
|