bigbluebutton-Github/bigbluebutton-html5/imports/api/pads/server/methods/padCapture.js
2023-01-14 18:00:29 +01:00

70 lines
2.1 KiB
JavaScript

import Pads, { PadsUpdates } from '/imports/api/pads';
import Breakouts from '/imports/api/breakouts';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
export default function padCapture(breakoutId, parentMeetingId) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'PadCapturePubMsg';
const EVENT_NAME_ERROR = 'PresentationConversionUpdateSysPubMsg';
const EXTERNAL_ID = Meteor.settings.public.notes.id;
try {
const pad = Pads.findOne(
{
meetingId: breakoutId,
externalId: EXTERNAL_ID,
},
{
fields: {
padId: 1,
},
},
);
const breakout = Breakouts.findOne({ breakoutId });
const update = PadsUpdates.findOne(
{
breakoutId,
externalId: EXTERNAL_ID,
}, {
fields: {
rev: 1,
},
},
);
const filename = `${breakout?.shortName}-notes`;
if (pad?.padId && update?.rev > 0 && breakout?.shortName) {
const payload = {
parentMeetingId,
breakoutId,
padId: pad.padId,
filename,
};
Logger.info(`Sending PadCapturePubMsg for meetingId=${breakoutId} parentMeetingId=${parentMeetingId} padId=${pad.padId}`);
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,
};
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);
} catch (err) {
Logger.error(`Exception while invoking method padCapture ${err.stack}`);
return null;
}
}