2021-10-16 03:07:13 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Captions from '/imports/api/captions';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-09 22:05:50 +08:00
|
|
|
export default async function updateCaptionsOwner(meetingId, locale, ownerId) {
|
2021-10-16 03:07:13 +08:00
|
|
|
try {
|
|
|
|
check(meetingId, String);
|
|
|
|
check(locale, String);
|
|
|
|
check(ownerId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
ownerId,
|
|
|
|
dictating: false, // Refresh dictation mode
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-03-09 22:05:50 +08:00
|
|
|
const numberAffected = await Captions.upsert(selector, modifier);
|
2021-10-16 03:07:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Added captions=${locale} owner=${ownerId} meeting=${meetingId}`);
|
|
|
|
} else {
|
|
|
|
Logger.info(`Upserted captions=${locale} owner=${ownerId} meeting=${meetingId}`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Adding captions owner to the collection: ${err}`);
|
|
|
|
}
|
|
|
|
}
|