feat(captions): Add SetUserSpeechLocaleMsg files

This commit is contained in:
Lucas Fialho Zawacki 2023-01-11 14:48:16 -03:00
parent 8200a0ef64
commit 4400cc68c8
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package org.bigbluebutton.core.apps.users
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.models.{ UserState, Users2x }
import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter }
import org.bigbluebutton.core.apps.{ PermissionCheck, RightsManagementTrait }
import org.bigbluebutton.core.domain.MeetingState2x
trait SetUserSpeechLocaleMsgHdlr extends RightsManagementTrait {
this: UsersApp =>
val liveMeeting: LiveMeeting
val outGW: OutMsgRouter
def handleSetUserSpeechLocaleReqMsg(msg: SetUserSpeechLocaleReqMsg): Unit = {
log.info("handleSetUserSpeechLocaleReqMsg: locale={} provider={} userId={}", msg.body.locale, msg.body.provider, msg.header.userId)
def broadcastUserSpeechLocaleChanged(user: UserState, locale: String, provider: String): Unit = {
val routingChange = Routing.addMsgToClientRouting(
MessageTypes.BROADCAST_TO_MEETING,
liveMeeting.props.meetingProp.intId, user.intId
)
val envelopeChange = BbbCoreEnvelope(UserSpeechLocaleChangedEvtMsg.NAME, routingChange)
val headerChange = BbbClientMsgHeader(UserSpeechLocaleChangedEvtMsg.NAME, liveMeeting.props.meetingProp.intId, user.intId)
val bodyChange = UserSpeechLocaleChangedEvtMsgBody(locale, provider)
val eventChange = UserSpeechLocaleChangedEvtMsg(headerChange, bodyChange)
val msgEventChange = BbbCommonEnvCoreMsg(envelopeChange, eventChange)
outGW.send(msgEventChange)
}
for {
user <- Users2x.findWithIntId(liveMeeting.users2x, msg.header.userId)
} yield {
var changeLocale: Option[UserState] = None;
changeLocale = Users2x.setUserSpeechLocale(liveMeeting.users2x, msg.header.userId, msg.body.locale)
broadcastUserSpeechLocaleChanged(user, msg.body.locale, msg.body.provider)
}
}
}

View File

@ -0,0 +1,13 @@
import { check } from 'meteor/check';
import updateSpeechLocale from '../modifiers/updateSpeechLocale';
export default function handleUserSpeechLocaleChanged({ body, header }, meetingId) {
const { locale } = body;
const { userId } = header;
check(meetingId, String);
check(userId, String);
check(locale, String);
return updateSpeechLocale(meetingId, userId, locale);
}