2022-04-01 03:40:07 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-02-15 03:07:24 +08:00
|
|
|
export default function updateTranscript(transcriptId, start, end, text, transcript, locale, isFinal) {
|
2022-04-01 03:40:07 +08:00
|
|
|
try {
|
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'UpdateTranscriptPubMsg';
|
|
|
|
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(transcriptId, String);
|
2022-04-28 03:42:07 +08:00
|
|
|
check(start, Number);
|
|
|
|
check(end, Number);
|
|
|
|
check(text, String);
|
2022-04-01 03:40:07 +08:00
|
|
|
check(transcript, String);
|
|
|
|
check(locale, String);
|
2023-02-15 03:07:24 +08:00
|
|
|
check(isFinal, Boolean);
|
2022-04-01 03:40:07 +08:00
|
|
|
|
2022-04-28 03:42:07 +08:00
|
|
|
// Ignore irrelevant updates
|
|
|
|
if (start !== -1 && end !== -1) {
|
|
|
|
const payload = {
|
|
|
|
transcriptId,
|
|
|
|
start,
|
|
|
|
end,
|
|
|
|
text,
|
|
|
|
transcript,
|
|
|
|
locale,
|
2023-02-15 03:07:24 +08:00
|
|
|
result: isFinal,
|
2022-04-28 03:42:07 +08:00
|
|
|
};
|
2022-04-01 03:40:07 +08:00
|
|
|
|
2022-04-28 03:42:07 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
|
|
}
|
2022-04-01 03:40:07 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method upadteTranscript ${err.stack}`);
|
|
|
|
}
|
|
|
|
}
|