2021-10-16 03:07:13 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Captions from '/imports/api/captions';
|
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import setDictation from '/imports/api/captions/server/modifiers/setDictation';
|
|
|
|
|
2023-03-09 22:05:50 +08:00
|
|
|
export default async function startDictation(locale) {
|
2021-10-16 03:07:13 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(locale, String);
|
|
|
|
|
2023-03-09 22:05:50 +08:00
|
|
|
const captions = await Captions.findOneAsync({
|
2021-10-16 03:07:13 +08:00
|
|
|
meetingId,
|
|
|
|
ownerId: requesterUserId,
|
|
|
|
locale,
|
|
|
|
});
|
|
|
|
|
2023-03-09 22:05:50 +08:00
|
|
|
if (captions) await setDictation(meetingId, locale, true);
|
2021-10-16 03:07:13 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method startDictation ${err.stack}`);
|
|
|
|
}
|
|
|
|
}
|