bigbluebutton-Github/bigbluebutton-html5/imports/api/pads/server/modifiers/updatePad.js
2023-03-20 16:38:31 -03:00

36 lines
969 B
JavaScript

import { check } from 'meteor/check';
import { PadsUpdates } from '/imports/api/pads';
import { getDataFromChangeset } from '/imports/api/pads/server/helpers';
import Logger from '/imports/startup/server/logger';
export default async function updatePad(meetingId, externalId, padId, userId, rev, changeset) {
try {
check(meetingId, String);
check(externalId, String);
check(padId, String);
check(userId, String);
check(rev, Number);
check(changeset, String);
const selector = {
meetingId,
externalId,
};
const modifier = {
$set: {
padId,
userId,
rev,
changeset,
data: getDataFromChangeset(changeset),
},
};
await PadsUpdates.upsertAsync(selector, modifier);
Logger.debug(`Added pad update external=${externalId} user=${userId} rev=${rev} meeting=${meetingId}`);
} catch (err) {
Logger.error(`Adding pad update to the collection: ${err}`);
}
}