Added audio caption table

This commit is contained in:
Paul Trudel 2023-08-09 19:44:45 +00:00
parent ba239f7b05
commit 3d86f0fd5a
5 changed files with 83 additions and 4 deletions

View File

@ -2,6 +2,7 @@ package org.bigbluebutton.core.apps.audiocaptions
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.db.AudioCaptionDAO
import org.bigbluebutton.core.models.AudioCaptions
import org.bigbluebutton.core.running.LiveMeeting
@ -12,6 +13,8 @@ trait UpdateTranscriptPubMsgHdlr {
val meetingId = liveMeeting.props.meetingProp.intId
def broadcastEvent(userId: String, transcriptId: String, transcript: String, locale: String, result: Boolean): Unit = {
AudioCaptionDAO.insertOrUpdateAudioCaption(transcriptId, meetingId, transcript)
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, meetingId, "nodeJSapp")
val envelope = BbbCoreEnvelope(TranscriptUpdatedEvtMsg.NAME, routing)
val header = BbbClientMsgHeader(TranscriptUpdatedEvtMsg.NAME, meetingId, userId)

View File

@ -0,0 +1,50 @@
package org.bigbluebutton.core.db
import slick.jdbc.PostgresProfile.api._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{ Failure, Success }
case class AudioCaptionDbModel(
transcriptId: String,
meetingId: String,
transcript: String
)
class AudioCaptionTableDef(tag: Tag) extends Table[AudioCaptionDbModel](tag, None, "audio_caption") {
val transcriptId = column[String]("transcriptId", O.PrimaryKey)
val meetingId = column[String]("meetingId")
val transcript = column[String]("transcript")
def * = (transcriptId, meetingId, transcript) <> (AudioCaptionDbModel.tupled, AudioCaptionDbModel.unapply)
}
object AudioCaptionDAO {
def insertOrUpdateAudioCaption(transcriptId: String, meetingId: String, transcript: String) = {
// DatabaseConnection.db.run(
// TableQuery[AudioCaptionTableDef]
// .filter(_.transcriptId === transcriptId)
// .map(a => a.transcript)
// .update((transcript))
// ).onComplete {
// case Success(rowsAffected) => rowsAffected match {
// case 0 => DatabaseConnection.db.run(
// TableQuery[AudioCaptionTableDef] += AudioCaptionDbModel(transcriptId, meetingId, transcript)
// ).onComplete {
// case Success => DatabaseConnection.logger.debug(s"Inserted new audio caption with ID $transcriptId on AudioCaption table")
// case Failure(e) => DatabaseConnection.logger.debug(s"Error inserting or updating audio caption on AudioCaption: $e")
// }
// case 1 => DatabaseConnection.logger.debug(s"Updated audio caption with ID $transcriptId on AudioCaption table")
// case n => DatabaseConnection.logger.debug(s"Error: Expected to insert or update a single row not $n rows")
// }
// case Failure(e) => DatabaseConnection.logger.debug(s"Error updating audio caption on AudioCaption: $e")
// }
TableQuery[AudioCaptionTableDef].insertOrUpdate(
AudioCaptionDbModel(
transcriptId = transcriptId,
meetingId = meetingId,
transcript = transcript
)
)
}
}

View File

@ -1282,3 +1282,15 @@ CREATE OR REPLACE VIEW "v_current_time" AS
SELECT
current_timestamp AS "currentTimestamp",
FLOOR(EXTRACT(EPOCH FROM current_timestamp) * 1000)::bigint AS "currentTimeMillis";
------------------------------------
----audioCaption
CREATE TABLE "audio_caption" (
"transcriptId" varchar(100) NOT NULL PRIMARY KEY,
"meetingId" varchar(100) REFERENCES "meeting"("meetingId") ON DELETE CASCADE,
"transcript" text
);
CREATE VIEW "v_audio_caption" AS
SELECT * FROM "audio_caption";

View File

@ -0,0 +1,13 @@
table:
name: v_audio_caption
schema: public
select_permissions:
- role: bbb_client
permission:
columns:
- transcriptId
- meetingId
- transcript
filter:
meetingId:
_eq: X-Hasura-PresenterInMeeting

View File

@ -1,15 +1,14 @@
- "!include public_v_chat_user.yaml"
- "!include public_v_meeting.yaml"
- "!include public_v_user_connectionStatus.yaml"
- "!include public_v_user_localSettings.yaml"
- "!include public_v_audio_caption.yaml"
- "!include public_v_breakoutRoom.yaml"
- "!include public_v_breakoutRoom_assignedUser.yaml"
- "!include public_v_breakoutRoom_participant.yaml"
- "!include public_v_chat.yaml"
- "!include public_v_chat_message_private.yaml"
- "!include public_v_chat_message_public.yaml"
- "!include public_v_chat_user.yaml"
- "!include public_v_current_time.yaml"
- "!include public_v_external_video.yaml"
- "!include public_v_meeting.yaml"
- "!include public_v_meeting_breakoutPolicies.yaml"
- "!include public_v_meeting_group.yaml"
- "!include public_v_meeting_lockSettings.yaml"
@ -34,10 +33,12 @@
- "!include public_v_user.yaml"
- "!include public_v_user_breakoutRoom.yaml"
- "!include public_v_user_camera.yaml"
- "!include public_v_user_connectionStatus.yaml"
- "!include public_v_user_connectionStatusReport.yaml"
- "!include public_v_user_current.yaml"
- "!include public_v_user_customParameter.yaml"
- "!include public_v_user_guest.yaml"
- "!include public_v_user_localSettings.yaml"
- "!include public_v_user_reaction.yaml"
- "!include public_v_user_reaction_current.yaml"
- "!include public_v_user_ref.yaml"