2022-03-25 03:05:20 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import AudioCaptions from '/imports/api/audio-captions';
|
2023-11-30 23:10:36 +08:00
|
|
|
import Users from '/imports/api/users';
|
2022-03-25 03:05:20 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-11-30 23:10:36 +08:00
|
|
|
export default async function setTranscript(userId, meetingId, transcriptId, transcript, locale) {
|
2022-03-25 03:05:20 +08:00
|
|
|
try {
|
|
|
|
check(meetingId, String);
|
2022-04-13 23:00:45 +08:00
|
|
|
check(transcriptId, String);
|
2022-03-25 03:05:20 +08:00
|
|
|
check(transcript, String);
|
|
|
|
|
2023-11-30 23:10:36 +08:00
|
|
|
const selector = { meetingId, transcriptId };
|
2022-03-25 03:05:20 +08:00
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
transcript,
|
2023-11-30 23:10:36 +08:00
|
|
|
lastUpdated: Math.floor(new Date().getTime()/1000),
|
|
|
|
locale,
|
2022-03-25 03:05:20 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-03-13 21:11:04 +08:00
|
|
|
const numberAffected = await AudioCaptions.upsertAsync(selector, modifier);
|
2022-03-25 03:05:20 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
2023-11-30 23:10:36 +08:00
|
|
|
Logger.debug(`Set transcriptId=${transcriptId} transcript=${transcript} meeting=${meetingId} locale=${locale}`);
|
2022-03-25 03:05:20 +08:00
|
|
|
} else {
|
2023-11-30 23:10:36 +08:00
|
|
|
Logger.debug(`Upserted transcriptId=${transcriptId} transcript=${transcript} meeting=${meetingId} locale=${locale}`);
|
2022-03-25 03:05:20 +08:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Setting audio captions transcript to the collection: ${err}`);
|
|
|
|
}
|
|
|
|
}
|