bigbluebutton-Github/bigbluebutton-html5/imports/api/pads/server/methods/padCapture.js

65 lines
2.0 KiB
JavaScript
Raw Normal View History

import Pads, { PadsUpdates } from '/imports/api/pads';
2022-09-25 04:59:29 +08:00
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
export default async function padCapture(breakoutId, parentMeetingId, filename) {
2022-09-25 04:59:29 +08:00
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'PadCapturePubMsg';
const EVENT_NAME_ERROR = 'PresentationConversionUpdateSysPubMsg';
2022-09-25 04:59:29 +08:00
const EXTERNAL_ID = Meteor.settings.public.notes.id;
2022-12-10 06:48:04 +08:00
try {
const pad = await Pads.findOneAsync(
2022-09-25 04:59:29 +08:00
{
2022-11-23 08:25:03 +08:00
meetingId: breakoutId,
2022-09-25 04:59:29 +08:00
externalId: EXTERNAL_ID,
},
{
fields: {
padId: 1,
},
},
);
const update = await PadsUpdates.findOneAsync(
{
2023-01-18 02:13:24 +08:00
meetingId: breakoutId,
externalId: EXTERNAL_ID,
}, {
fields: {
rev: 1,
},
},
);
2023-01-17 07:10:13 +08:00
if (pad?.padId && update?.rev > 0) {
2022-11-23 08:25:03 +08:00
const payload = {
parentMeetingId,
breakoutId,
padId: pad.padId,
filename,
2022-11-23 08:25:03 +08:00
};
Logger.info(`Sending PadCapturePubMsg for meetingId=${breakoutId} parentMeetingId=${parentMeetingId} padId=${pad.padId}`);
2022-09-25 04:59:29 +08:00
return RedisPubSub.publishMeetingMessage(CHANNEL, EVENT_NAME, parentMeetingId, payload);
}
// Notify that no content is available
const temporaryPresentationId = `${breakoutId}-notes`;
const payload = {
podId: 'DEFAULT_PRESENTATION_POD',
messageKey: '204',
code: 'not-used',
presentationId: temporaryPresentationId,
presName: filename,
temporaryPresentationId,
};
2023-01-08 23:15:16 +08:00
Logger.info(`No notes available for capture in meetingId=${breakoutId} parentMeetingId=${parentMeetingId} padId=${pad.padId}`);
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME_ERROR, parentMeetingId, 'system', payload);
2022-09-25 04:59:29 +08:00
} catch (err) {
Logger.error(`Exception while invoking method padCapture ${err.stack}`);
return null;
}
}