2019-02-16 03:45:42 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Presentations from '/imports/api/presentations';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-15 01:27:52 +08:00
|
|
|
export default async function setPresentationDownloadable(meetingId, podId,
|
2023-08-10 23:18:59 +08:00
|
|
|
presentationId, downloadable, extensionToBeDownloadable) {
|
2019-02-16 03:45:42 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(presentationId, String);
|
|
|
|
check(podId, String);
|
|
|
|
check(downloadable, Boolean);
|
2023-08-10 23:18:59 +08:00
|
|
|
check(extensionToBeDownloadable, String);
|
2019-02-16 03:45:42 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
podId,
|
|
|
|
id: presentationId,
|
|
|
|
};
|
|
|
|
|
2023-08-10 23:18:59 +08:00
|
|
|
let downloadableExtension = extensionToBeDownloadable;
|
|
|
|
if (!downloadable) {
|
|
|
|
downloadableExtension = '';
|
|
|
|
}
|
2019-02-16 03:45:42 +08:00
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
downloadable,
|
2023-08-10 23:18:59 +08:00
|
|
|
downloadableExtension,
|
2019-02-16 03:45:42 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
2023-03-15 01:27:52 +08:00
|
|
|
const { numberAffected } = await Presentations.upsertAsync(selector, modifier);
|
2019-02-16 03:45:42 +08:00
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
if (numberAffected) {
|
2019-02-16 03:45:42 +08:00
|
|
|
Logger.info(`Set downloadable status on presentation {${presentationId} in meeting {${meetingId}}`);
|
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Could not set downloadable on pres {${presentationId} in meeting {${meetingId}} ${err}`);
|
|
|
|
}
|
2019-02-16 03:45:42 +08:00
|
|
|
}
|