2022-12-28 05:23:13 +08:00
|
|
|
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';
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
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';
|
2023-01-15 01:00:29 +08:00
|
|
|
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 {
|
2023-03-16 22:00:45 +08:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2023-03-16 22:00:45 +08:00
|
|
|
const update = await PadsUpdates.findOneAsync(
|
2022-12-28 05:23:13 +08:00
|
|
|
{
|
2023-01-18 02:13:24 +08:00
|
|
|
meetingId: breakoutId,
|
2022-12-28 05:23:13 +08:00
|
|
|
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,
|
2023-01-14 20:43:38 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2023-01-14 20:43:38 +08:00
|
|
|
// Notify that no content is available
|
2023-01-15 01:00:29 +08:00
|
|
|
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
|
|
|
|
2023-01-15 01:00:29 +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;
|
|
|
|
}
|
|
|
|
}
|