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';
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
export default async function createPad(meetingId, externalId, padId) {
|
2021-10-16 03:07:13 +08:00
|
|
|
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
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
const { insertedId } = await Pads.upsertAsync(selector, modifier);
|
2021-10-16 03:07:13 +08:00
|
|
|
|
|
|
|
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}`);
|
|
|
|
}
|
|
|
|
}
|