diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserVoiceDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserVoiceDAO.scala index 9110d5a27c..50839879a9 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserVoiceDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserVoiceDAO.scala @@ -7,8 +7,8 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.util.{Failure, Success } case class UserVoiceDbModel( - voiceUserId: String, userId: String, + voiceUserId: String, callerName: String, callerNum: String, callingWith: String, @@ -27,11 +27,11 @@ case class UserVoiceDbModel( class UserVoiceDbTableDef(tag: Tag) extends Table[UserVoiceDbModel](tag, None, "user_voice") { override def * = ( - voiceUserId, userId, callerName, callerNum, callingWith, joined, listenOnly, + userId, voiceUserId, callerName, callerNum, callingWith, joined, listenOnly, muted, spoke, talking, floor, lastFloorTime, voiceConf, color, startTime, endTime ) <> (UserVoiceDbModel.tupled, UserVoiceDbModel.unapply) - val voiceUserId = column[String]("voiceUserId", O.PrimaryKey) - val userId = column[String]("userId") + val userId = column[String]("userId", O.PrimaryKey) + val voiceUserId = column[String]("voiceUserId") val callerName = column[String]("callerName") val callerNum = column[String]("callerNum") val callingWith = column[String]("callingWith") @@ -53,11 +53,14 @@ object UserVoiceDAO { // val usersTable = TableQuery[UserTableDef] def insert(voiceUserState: VoiceUserState) = { + println("Will add!") + println(voiceUserState) + DatabaseConnection.db.run( - TableQuery[UserVoiceDbTableDef].forceInsert( + TableQuery[UserVoiceDbTableDef].insertOrUpdate( UserVoiceDbModel( - voiceUserId = voiceUserState.voiceUserId, userId = voiceUserState.intId, + voiceUserId = voiceUserState.voiceUserId, callerName = voiceUserState.callerName, callerNum = voiceUserState.callerNum, callingWith = voiceUserState.callingWith, @@ -85,7 +88,7 @@ object UserVoiceDAO { def update(voiceUserState: VoiceUserState) = { DatabaseConnection.db.run( TableQuery[UserVoiceDbTableDef] - .filter(_.voiceUserId === voiceUserState.voiceUserId) + .filter(_.userId === voiceUserState.intId) .map(u => (u.listenOnly, u.muted, u.floor, u.lastFloorTime)) .update((voiceUserState.listenOnly, voiceUserState.muted, voiceUserState.floor, voiceUserState.lastFloorTime)) ).onComplete { @@ -104,13 +107,13 @@ object UserVoiceDAO { "spoke" = true, "endTime" = null, "startTime" = (case when "talking" is false then $now else "startTime" end) - WHERE "voiceUserId" = ${voiceUserState.voiceUserId}""" + WHERE "userId" = ${voiceUserState.intId}""" } else { sqlu"""UPDATE user_voice SET "talking" = false, "startTime" = null, "endTime" = (case when "talking" is true then $now else "endTime" end) - WHERE "voiceUserId" = ${voiceUserState.voiceUserId}""" + WHERE "userId" = ${voiceUserState.intId}""" } DatabaseConnection.db.run(updateSql).onComplete { @@ -119,18 +122,14 @@ object UserVoiceDAO { } } - def delete(voiceUserId: String) = { - DatabaseConnection.db.run( - TableQuery[UserVoiceDbTableDef] - .filter(_.voiceUserId === voiceUserId) - .delete - ).onComplete { - case Success(rowsAffected) => println(s"Voice ${voiceUserId} deleted") - case Failure(e) => println(s"Error deleting voice: $e") - } - } - def deleteUser(userId: String) = { + //Meteor sets this props instead of removing + // muted: false + // talking: false + // listenOnly: false + // joined: false + // spoke: false + DatabaseConnection.db.run( TableQuery[UserVoiceDbTableDef] .filter(_.userId === userId) diff --git a/bbb-graphql-client-test/src/App.js b/bbb-graphql-client-test/src/App.js index 3e4f06e54a..6fcbb2cd5a 100644 --- a/bbb-graphql-client-test/src/App.js +++ b/bbb-graphql-client-test/src/App.js @@ -106,7 +106,7 @@ function App() {
-
+

diff --git a/bbb-graphql-client-test/src/UserList.js b/bbb-graphql-client-test/src/UserList.js index 9dd9a8c134..bf263187fc 100644 --- a/bbb-graphql-client-test/src/UserList.js +++ b/bbb-graphql-client-test/src/UserList.js @@ -35,7 +35,7 @@ function UserList() { clientType leftFlag loggedOut - voices { + voice { joined listenOnly talking @@ -52,7 +52,7 @@ function UserList() { isDefaultName sequence shortName - online + currentlyInRoom } } }` @@ -99,13 +99,13 @@ function UserList() { 0 ? '#A0DAA9' : ''}}>{user.cameras.length > 0 ? 'Yes' : 'No'} 0 ? '#A0DAA9' : ''}}>{user.presPagesWritable.length > 0 ? 'Yes' : 'No'} {user.pinned === true ? 'Yes' : 'No'} - 0 ? '#A0DAA9' : ''}}>{user.voices.length > 0 ? 'Yes' : 'No'} - m.listenOnly === true).length > 0 ? '#A0DAA9' : ''}}>{user.voices.filter(m => m.listenOnly === true).length > 0 ? 'Yes' : 'No'} - m.talking === true).length > 0 ? '#A0DAA9' : ''}}>{user.voices.filter(m => m.talking === true).length > 0 ? 'Yes' : 'No'} - m.muted === true).length > 0 ? '#A0DAA9' : ''}}>{user.voices.filter(m => m.muted === true).length > 0 ? 'Yes' : 'No'} + {user.voice?.joined === true ? 'Yes' : 'No'} + {user.voice?.listenOnly === true ? 'Yes' : 'No'} + {user.voice?.talking === true ? 'Yes' : 'No'} + {user.voice?.muted === true ? 'Yes' : 'No'} {user.locked === true ? 'Yes' : 'No'} - - {user.lastBreakoutRoom?.shortName}{user.lastBreakoutRoom?.online == true ? ' (Online)' : ''} + + {user.lastBreakoutRoom?.shortName}{user.lastBreakoutRoom?.currentlyInRoom == true ? ' (Online)' : ''} {user.leftFlag === true ? 'Yes' : 'No'} {user.loggedOut === true ? 'Yes' : 'No'} diff --git a/bbb-graphql-server/bbb_schema.sql b/bbb-graphql-server/bbb_schema.sql index f5d690aee2..8d2340294f 100644 --- a/bbb-graphql-server/bbb_schema.sql +++ b/bbb-graphql-server/bbb_schema.sql @@ -177,8 +177,8 @@ CREATE TABLE public."user" ( CREATE INDEX "idx_user_meetingId" ON "user"("meetingId"); CREATE TABLE "user_voice" ( - "voiceUserId" varchar(100) PRIMARY KEY, - "userId" varchar(50) NOT NULL REFERENCES "user"("userId") ON DELETE CASCADE, + "userId" varchar(50) PRIMARY KEY NOT NULL REFERENCES "user"("userId") ON DELETE CASCADE, + "voiceUserId" varchar(100), "callerName" varchar(100), "callerNum" varchar(100), "callingWith" varchar(100), @@ -194,7 +194,7 @@ CREATE TABLE "user_voice" ( "endTime" bigint NULL, "startTime" bigint NULL ); -CREATE INDEX "idx_user_voice_userId" ON "user_voice"("userId"); +--CREATE INDEX "idx_user_voice_userId" ON "user_voice"("userId"); CREATE OR REPLACE VIEW "v_user_voice" AS SELECT