2022-04-14 21:59:54 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2022-12-24 03:13:26 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2022-04-14 21:59:54 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
|
2022-04-28 22:06:19 +08:00
|
|
|
const LANGUAGES = Meteor.settings.public.app.audioCaptions.language.available;
|
2022-04-14 21:59:54 +08:00
|
|
|
|
2022-12-24 03:13:26 +08:00
|
|
|
export default function setSpeechLocale(locale, provider) {
|
2022-04-14 21:59:54 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
2022-12-24 03:13:26 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'SetUserSpeechLocaleReqMsg';
|
|
|
|
|
2022-04-14 21:59:54 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(locale, String);
|
2022-12-24 03:13:26 +08:00
|
|
|
check(provider, String);
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
locale,
|
|
|
|
provider,
|
|
|
|
};
|
2022-04-14 21:59:54 +08:00
|
|
|
|
|
|
|
if (LANGUAGES.includes(locale) || locale === '') {
|
2022-12-24 03:13:26 +08:00
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
2022-04-14 21:59:54 +08:00
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method setSpeechLocale ${err.stack}`);
|
|
|
|
}
|
|
|
|
}
|