diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/AudioCaptionsApp2x.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/AudioCaptionsApp2x.scala index 93abe8bdb9..987aa4a216 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/AudioCaptionsApp2x.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/AudioCaptionsApp2x.scala @@ -4,6 +4,7 @@ import akka.actor.ActorContext class AudioCaptionsApp2x(implicit val context: ActorContext) extends UpdateTranscriptPubMsgHdlr + with TranscriptionProviderErrorMsgHdlr with AudioFloorChangedVoiceConfEvtMsgHdlr { } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/TranscriptionProviderErrorMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/TranscriptionProviderErrorMsgHdlr.scala new file mode 100644 index 0000000000..a652050822 --- /dev/null +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/audiocaptions/TranscriptionProviderErrorMsgHdlr.scala @@ -0,0 +1,27 @@ +package org.bigbluebutton.core.apps.audiocaptions + +import org.bigbluebutton.common2.msgs._ +import org.bigbluebutton.core.bus.MessageBus +import org.bigbluebutton.core.models.AudioCaptions +import org.bigbluebutton.core.running.LiveMeeting + +trait TranscriptionProviderErrorMsgHdlr { + this: AudioCaptionsApp2x => + + def handleTranscriptionProviderErrorMsg(msg: TranscriptionProviderErrorMsg, liveMeeting: LiveMeeting, bus: MessageBus): Unit = { + val meetingId = liveMeeting.props.meetingProp.intId + + def broadcastEvent(userId: String, errorCode: String, errorMessage: String): Unit = { + val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, meetingId, "nodeJSapp") + val envelope = BbbCoreEnvelope(TranscriptionProviderErrorEvtMsg.NAME, routing) + val header = BbbClientMsgHeader(TranscriptionProviderErrorEvtMsg.NAME, meetingId, userId) + val body = TranscriptionProviderErrorEvtMsgBody(errorCode, errorMessage) + val event = TranscriptionProviderErrorEvtMsg(header, body) + val msgEvent = BbbCommonEnvCoreMsg(envelope, event) + + bus.outGW.send(msgEvent) + } + + broadcastEvent(msg.header.userId, msg.body.errorCode, msg.body.errorMessage) + } +} diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala index 72f6df7592..76e0995b3d 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala @@ -406,6 +406,8 @@ class ReceivedJsonMsgHandlerActor( // AudioCaptions case UpdateTranscriptPubMsg.NAME => routeGenericMsg[UpdateTranscriptPubMsg](envelope, jsonNode) + case TranscriptionProviderErrorMsg.NAME => + routeGenericMsg[TranscriptionProviderErrorMsg](envelope, jsonNode) // GroupChats case GetGroupChatsReqMsg.NAME => diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala index 19b482b0a2..aa84f65a01 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala @@ -583,6 +583,7 @@ class MeetingActor( // AudioCaptions case m: UpdateTranscriptPubMsg => audioCaptionsApp2x.handle(m, liveMeeting, msgBus) + case m: TranscriptionProviderErrorMsg => audioCaptionsApp2x.handleTranscriptionProviderErrorMsg(m, liveMeeting, msgBus) // GroupChat case m: CreateGroupChatReqMsg => diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/AudioCaptionsMsgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/AudioCaptionsMsgs.scala index 495f325f45..64e6f672cd 100644 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/AudioCaptionsMsgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/AudioCaptionsMsgs.scala @@ -1,5 +1,12 @@ package org.bigbluebutton.common2.msgs +object TranscriptionProviderErrorMsg { val NAME = "TranscriptionProviderErrorMsg" } +case class TranscriptionProviderErrorMsg(header: BbbClientMsgHeader, body: TranscriptionProviderErrorMsgBody) extends StandardMsg +case class TranscriptionProviderErrorMsgBody( + errorCode: String, + errorMessage: String, +) + // In messages object UpdateTranscriptPubMsg { val NAME = "UpdateTranscriptPubMsg" } case class UpdateTranscriptPubMsg(header: BbbClientMsgHeader, body: UpdateTranscriptPubMsgBody) extends StandardMsg @@ -14,6 +21,10 @@ case class UpdateTranscriptPubMsgBody( ) // Out messages +object TranscriptionProviderErrorEvtMsg { val NAME = "TranscriptionProviderErrorEvtMsg" } +case class TranscriptionProviderErrorEvtMsg(header: BbbClientMsgHeader, body: TranscriptionProviderErrorEvtMsgBody) extends BbbCoreMsg +case class TranscriptionProviderErrorEvtMsgBody(errorCode: String, errorMessage: String) + object TranscriptUpdatedEvtMsg { val NAME = "TranscriptUpdatedEvtMsg" } case class TranscriptUpdatedEvtMsg(header: BbbClientMsgHeader, body: TranscriptUpdatedEvtMsgBody) extends BbbCoreMsg case class TranscriptUpdatedEvtMsgBody(transcriptId: String, transcript: String, locale: String, result: Boolean) diff --git a/bigbluebutton-html5/imports/api/audio-captions/server/eventHandlers.js b/bigbluebutton-html5/imports/api/audio-captions/server/eventHandlers.js index 9a8e2f1a96..1ac7583062 100644 --- a/bigbluebutton-html5/imports/api/audio-captions/server/eventHandlers.js +++ b/bigbluebutton-html5/imports/api/audio-captions/server/eventHandlers.js @@ -1,4 +1,6 @@ import RedisPubSub from '/imports/startup/server/redis'; import handleTranscriptUpdated from '/imports/api/audio-captions/server/handlers/transcriptUpdated'; +import handleTranscriptionProviderError from '/imports/api/audio-captions/server/handlers/transcriptionProviderError'; RedisPubSub.on('TranscriptUpdatedEvtMsg', handleTranscriptUpdated); +RedisPubSub.on('TranscriptionProviderErrorEvtMsg', handleTranscriptionProviderError); diff --git a/bigbluebutton-html5/imports/api/audio-captions/server/handlers/transcriptionProviderError.js b/bigbluebutton-html5/imports/api/audio-captions/server/handlers/transcriptionProviderError.js new file mode 100644 index 0000000000..ab5c5ae964 --- /dev/null +++ b/bigbluebutton-html5/imports/api/audio-captions/server/handlers/transcriptionProviderError.js @@ -0,0 +1,38 @@ +import Users from '/imports/api/users'; +import Logger from '/imports/startup/server/logger'; + +export default async function handleTranscriptionProviderError({ header, body }) { + const { + meetingId, + userId, + } = header; + + const selector = { + meetingId, + userId, + }; + + const { + errorCode, + errorMessage, + } = body; + + const modifier = { + $set: { + transcriptionError: { + code: errorCode, + message: errorMessage, + }, + }, + }; + + try { + const numberAffected = await Users.updateAsync(selector, modifier); + + if (numberAffected) { + Logger.error(`Transcription error errorCode=${errorCode} errorMessage=${errorMessage} meetingId=${meetingId}`); + } + } catch (err) { + Logger.error(`Problem setting transcription error: ${err}`); + } +}