From 93c52542aef6177f45f164021c68c73e2d9003b2 Mon Sep 17 00:00:00 2001 From: Gustavo Trott Date: Wed, 5 Apr 2023 16:47:14 -0300 Subject: [PATCH] Clear codes related to Scala/Slick --- .../core/BigBlueButtonActor.scala | 3 +- .../core/apps/WhiteboardModel.scala | 9 +-- .../apps/users/RegisterUserReqMsgHdlr.scala | 8 +-- .../voice/UserJoinedVoiceConfEvtMsgHdlr.scala | 5 +- .../bigbluebutton/core/db/MeetingDAO.scala | 2 - .../core/db/PostgresProfile.scala | 61 ++++++++++------- .../core/db/PresAnnotationDAO.scala | 47 +------------ .../core/db/PresAnnotationHistoryDAO.scala | 67 +------------------ .../bigbluebutton/core/db/PresPageDAO.scala | 6 -- .../core/db/PresPresentationDAO.scala | 2 - .../org/bigbluebutton/core/db/UserDAO.scala | 22 ------ .../bigbluebutton/core/db/UserVoiceDAO.scala | 3 - .../bigbluebutton/core/models/Users2x.scala | 4 +- .../core/util/RandomStringGenerator.scala | 7 ++ 14 files changed, 57 insertions(+), 189 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala index b76dcb67dc..887e398dca 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala @@ -186,7 +186,8 @@ class BigBlueButtonActor( } MeetingDAO.delete(msg.meetingId) - UserDAO.deleteAllFromMeeting(msg.meetingId) + // Removing the meeting is enough, all other tables has "ON DELETE CASCADE" + // UserDAO.deleteAllFromMeeting(msg.meetingId) } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala index fa244f5a70..7908a30d00 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/WhiteboardModel.scala @@ -22,15 +22,13 @@ class WhiteboardModel extends SystemConfiguration { } private def createWhiteboard(wbId: String): Whiteboard = { - val newWb = Whiteboard( + Whiteboard( wbId, Array.empty[String], Array.empty[String], System.currentTimeMillis(), new HashMap[String, AnnotationVO] ) - - newWb } private def deepMerge(test: Map[String, _], that: Map[String, _]): Map[String, _] = @@ -76,10 +74,6 @@ class WhiteboardModel extends SystemConfiguration { } val newWb = wb.copy(annotationsMap = newAnnotationsMap) saveWhiteboard(newWb) - - //Use it to add the diff only - // annotationsAdded.map(PresAnnotationDAO.insertOrUpdate(_)) - annotationsAdded } @@ -118,7 +112,6 @@ class WhiteboardModel extends SystemConfiguration { def modifyWhiteboardAccess(wbId: String, multiUser: Array[String]) { val wb = getWhiteboard(wbId) val newWb = wb.copy(multiUser = multiUser, oldMultiUser = wb.multiUser, changedModeOn = System.currentTimeMillis()) - // UserWhiteboardDAO.updateMultiuser(newWb) PresPageWritersDAO.updateMultiuser(newWb) saveWhiteboard(newWb) } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala index 9346ba2286..bf128158ce 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/RegisterUserReqMsgHdlr.scala @@ -3,7 +3,9 @@ package org.bigbluebutton.core.apps.users import org.bigbluebutton.common2.msgs._ import org.bigbluebutton.core.models._ import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter } +import org.bigbluebutton.core.util.RandomStringGenerator import org.bigbluebutton.core2.message.senders.{ MsgBuilder, Sender } + import scala.util.Random trait RegisterUserReqMsgHdlr { @@ -55,13 +57,9 @@ trait RegisterUserReqMsgHdlr { val guestStatus = msg.body.guestStatus - val colorOptions = List("#7b1fa2", "#6a1b9a", "#4a148c", "#5e35b1", "#512da8", "#4527a0", "#311b92", - "#3949ab", "#303f9f", "#283593", "#1a237e", "#1976d2", "#1565c0", "#0d47a1", "#0277bd", "#01579b") - val userColor = colorOptions(Random.nextInt(colorOptions.length)) - val regUser = RegisteredUsers.create(msg.body.intUserId, msg.body.extUserId, msg.body.name, msg.body.role, msg.body.authToken, - msg.body.avatarURL, userColor, msg.body.guest, msg.body.authed, guestStatus, msg.body.excludeFromDashboard, false) + msg.body.avatarURL, RandomStringGenerator.randomColor, msg.body.guest, msg.body.authed, guestStatus, msg.body.excludeFromDashboard, false) checkUserConcurrentAccesses(regUser) RegisteredUsers.add(liveMeeting.registeredUsers, regUser, liveMeeting.props.meetingProp.intId) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala index aae39c4560..c31216bbef 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/UserJoinedVoiceConfEvtMsgHdlr.scala @@ -6,6 +6,7 @@ import org.bigbluebutton.core.running.{ LiveMeeting, MeetingActor, OutMsgRouter import org.bigbluebutton.core2.message.senders.MsgBuilder import org.bigbluebutton.core.models._ import org.bigbluebutton.core.apps.users.UsersApp +import org.bigbluebutton.core.util.RandomStringGenerator import org.bigbluebutton.core2.MeetingStatus2x import scala.util.Random @@ -21,9 +22,7 @@ trait UserJoinedVoiceConfEvtMsgHdlr extends SystemConfiguration { val guestPolicy = GuestsWaiting.getGuestPolicy(liveMeeting.guestsWaiting) val isDialInUser = msg.body.intId.startsWith(IntIdPrefixType.DIAL_IN) - val colorOptions = List("#7b1fa2", "#6a1b9a", "#4a148c", "#5e35b1", "#512da8", "#4527a0", "#311b92", - "#3949ab", "#303f9f", "#283593", "#1a237e", "#1976d2", "#1565c0", "#0d47a1", "#0277bd", "#01579b") - val userColor = colorOptions(Random.nextInt(colorOptions.length)) + val userColor = RandomStringGenerator.randomColor def notifyModeratorsOfGuestWaiting(guest: GuestWaiting, users: Users2x, meetingId: String): Unit = { val moderators = Users2x.findAll(users).filter(p => p.role == Roles.MODERATOR_ROLE) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/MeetingDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/MeetingDAO.scala index 2efd769adb..802262031a 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/MeetingDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/MeetingDAO.scala @@ -53,8 +53,6 @@ class MeetingDbTableDef(tag: Tag) extends Table[MeetingDbModel](tag, None, "meet } object MeetingDAO { - // val usersTable = TableQuery[UserTableDef] - def insert(meetingProps: DefaultProps) = { DatabaseConnection.db.run( TableQuery[MeetingDbTableDef].forceInsert( diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PostgresProfile.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PostgresProfile.scala index 21151eee54..0eae969d2c 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PostgresProfile.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PostgresProfile.scala @@ -1,41 +1,52 @@ package org.bigbluebutton.core.db import com.github.tminglei.slickpg._ +import spray.json.{ JsArray, JsBoolean, JsNumber, JsObject, JsString, JsValue, JsonWriter } +import spray.json.{ _ } trait PostgresProfile extends ExPostgresProfile - with PgArraySupport // with PgDate2Support - // with PgRangeSupport - // with PgHStoreSupport - // with PgPlayJsonSupport - // with PgSearchSupport - // with PgPostGISSupport - // with PgNetSupport - // with PgLTreeSupport - { - def pgjson = "jsonb" // jsonb support is in postgres 9.4.0 onward; for 9.3.x use "json" + with PgArraySupport { + // def pgjson = "jsonb" // jsonb support is in postgres 9.4.0 onward; for 9.3.x use "json" // Add back `capabilities.insertOrUpdate` to enable native `upsert` support; for postgres 9.5+ override protected def computeCapabilities: Set[slick.basic.Capability] = super.computeCapabilities + slick.jdbc.JdbcCapabilities.insertOrUpdate - override val api = MyAPI + override val api = PgAPI - object MyAPI extends API with ArrayImplicits // with DateTimeImplicits - // with JsonImplicits - // with NetImplicits - // with LTreeImplicits - // with RangeImplicits - // with HStoreImplicits - // with SearchImplicits - // with SearchAssistants + object PgAPI extends API with ArrayImplicits // with DateTimeImplicits { implicit val strListTypeMapper = new SimpleArrayJdbcType[String]("text").to(_.toList) - // implicit val playJsonArrayTypeMapper = - // new AdvancedArrayJdbcType[JsValue](pgjson, - // (s) => utils.SimpleArrayUtils.fromString[JsValue](Json.parse(_))(s).orNull, - // (v) => utils.SimpleArrayUtils.mkString[JsValue](_.toString())(v) - // ).to(_.toList) } + } -object PostgresProfile extends PostgresProfile \ No newline at end of file +object PostgresProfile extends PostgresProfile + +object JsonUtils { + implicit object AnyJsonWriter extends JsonWriter[Any] { + def write(x: Any): JsValue = x match { + case n: Int => JsNumber(n) + case s: String => JsString(s) + case b: Boolean => JsBoolean(b) + case f: Float => JsNumber(f) + case d: Double => JsNumber(d) + case m: Map[_, _] => JsObject(m.asInstanceOf[Map[String, Any]].map { case (k, v) => k -> write(v) }) + case l: List[_] => JsArray(l.map(write).toVector) + case _ => throw new IllegalArgumentException(s"Unsupported type: ${x.getClass.getName}") + // case _ => JsNull + } + } + + // Cria um JsonWriter implícito para o tipo Map[String, Any] + implicit val mapFormat: JsonWriter[Map[String, Any]] = new JsonWriter[Map[String, Any]] { + def write(m: Map[String, Any]): JsValue = { + JsObject(m.map { case (k, v) => k -> AnyJsonWriter.write(v) }) + } + } + + def mapToJson(genericMap: Map[String, Any]) = { + genericMap.toJson.compactPrint + } + +} \ No newline at end of file diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationDAO.scala index 598785ba85..514beb1226 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationDAO.scala @@ -1,12 +1,8 @@ package org.bigbluebutton.core.db import org.bigbluebutton.common2.msgs.AnnotationVO -import slick.jdbc.PostgresProfile.api._ -import spray.json.{ JsValue, _ } - -import scala.concurrent.Await +import PostgresProfile.api._ import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.duration.Duration import scala.util.{ Failure, Success } case class PresAnnotationDbModel( @@ -30,45 +26,6 @@ class PresAnnotationDbTableDef(tag: Tag) extends Table[PresAnnotationDbModel](ta } object PresAnnotationDAO { - implicit object AnyJsonWriter extends JsonWriter[Any] { - def write(x: Any): JsValue = x match { - case n: Int => JsNumber(n) - case s: String => JsString(s) - case b: Boolean => JsBoolean(b) - case f: Float => JsNumber(f) - case d: Double => JsNumber(d) - case m: Map[_, _] => JsObject(m.asInstanceOf[Map[String, Any]].map { case (k, v) => k -> write(v) }) - case l: List[_] => JsArray(l.map(write).toVector) - case _ => throw new IllegalArgumentException(s"Unsupported type: ${x.getClass.getName}") - // case _ => JsNull - } - } - - // Cria um JsonWriter implícito para o tipo Map[String, Any] - implicit val mapFormat: JsonWriter[Map[String, Any]] = new JsonWriter[Map[String, Any]] { - def write(m: Map[String, Any]): JsValue = { - JsObject(m.map { case (k, v) => k -> AnyJsonWriter.write(v) }) - } - } - - // def insertOrUpdate(annotation: AnnotationVO) = { - // DatabaseConnection.db.run( - // TableQuery[PresAnnotationDbTableDef].insertOrUpdate( - // PresAnnotationDbModel( - // annotationId = annotation.id, - // pageId = annotation.wbId, - // userId = annotation.userId, - // annotationInfo = annotation.annotationInfo.toMap.toJson.compactPrint, - // // annotationInfo = annotation.annotationInfo.toString(), - // lastUpdatedAt = new java.sql.Timestamp(System.currentTimeMillis()) - // ) - // ) - // ).onComplete { - // case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) inserted on PresAnnotation table!") - // case Failure(e) => DatabaseConnection.logger.debug(s"Error inserting PresAnnotation: $e") - // } - // } - def insertOrUpdate(annotation: AnnotationVO, annotationDiff: AnnotationVO) = { PresAnnotationHistoryDAO.insert(annotationDiff).onComplete { case Success(sequence) => { @@ -79,7 +36,7 @@ object PresAnnotationDAO { annotationId = annotation.id, pageId = annotation.wbId, userId = annotation.userId, - annotationInfo = annotation.annotationInfo.toJson.compactPrint, + annotationInfo = JsonUtils.mapToJson(annotation.annotationInfo), lastHistorySequence = sequence.getOrElse(0), lastUpdatedAt = new java.sql.Timestamp(System.currentTimeMillis()) ) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationHistoryDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationHistoryDAO.scala index bb3be08381..ca0f5e8a83 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationHistoryDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationHistoryDAO.scala @@ -1,11 +1,7 @@ package org.bigbluebutton.core.db import org.bigbluebutton.common2.msgs.AnnotationVO -import slick.jdbc.PostgresProfile.api._ -import spray.json.{ JsValue, _ } - -import scala.concurrent.ExecutionContext.Implicits.global -import scala.util.{ Failure, Success } +import PostgresProfile.api._ case class PresAnnotationHistoryDbModel( sequence: Option[Int] = None, @@ -28,26 +24,6 @@ class PresAnnotationHistoryDbTableDef(tag: Tag) extends Table[PresAnnotationHist } object PresAnnotationHistoryDAO { - implicit object AnyJsonWriter extends JsonWriter[Any] { - def write(x: Any): JsValue = x match { - case n: Int => JsNumber(n) - case s: String => JsString(s) - case b: Boolean => JsBoolean(b) - case f: Float => JsNumber(f) - case d: Double => JsNumber(d) - case m: Map[_, _] => JsObject(m.asInstanceOf[Map[String, Any]].map { case (k, v) => k -> write(v) }) - case l: List[_] => JsArray(l.map(write).toVector) - case _ => throw new IllegalArgumentException(s"Unsupported type: ${x.getClass.getName}") - // case _ => JsNull - } - } - - // Cria um JsonWriter implícito para o tipo Map[String, Any] - implicit val mapFormat: JsonWriter[Map[String, Any]] = new JsonWriter[Map[String, Any]] { - def write(m: Map[String, Any]): JsValue = { - JsObject(m.map { case (k, v) => k -> AnyJsonWriter.write(v) }) - } - } def insert(annotationDiff: AnnotationVO) = { DatabaseConnection.db.run( @@ -58,7 +34,7 @@ object PresAnnotationHistoryDAO { annotationId = annotationDiff.id, pageId = annotationDiff.wbId, userId = annotationDiff.userId, - annotationInfo = annotationDiff.annotationInfo.toJson.compactPrint + annotationInfo = JsonUtils.mapToJson(annotationDiff.annotationInfo) ) ) } @@ -75,44 +51,5 @@ object PresAnnotationHistoryDAO { annotationInfo = "" ) ) - // DatabaseConnection.db.run( - // TableQuery[PresAnnotationDbTableDef] - // .filter(_.annotationId === annotationId) - // .map(a => (a.annotationInfo, a.lastUpdatedAt)) - // .update("", new java.sql.Timestamp(System.currentTimeMillis())) - // ).onComplete { - // case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) updated annotationInfo=null on PresAnnotation table!") - // case Failure(e) => DatabaseConnection.logger.debug(s"Error updating annotationInfo=null PresAnnotation: $e") - // } } - - // def insertOrUpdate(annotation: AnnotationVO) = { - // DatabaseConnection.db.run( - // TableQuery[PresAnnotationHistoryDbTableDef].insertOrUpdate( - // PresAnnotationHistoryDbModel( - // sequence = None, - // annotationId = annotation.id, - // pageId = annotation.wbId, - // userId = annotation.userId, - // annotationInfo = annotation.annotationInfo.toJson.compactPrint - // ) - // ) - // ).onComplete { - // case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) inserted on PresAnnotationHistory table!") - // case Failure(e) => DatabaseConnection.logger.debug(s"Error inserting PresAnnotationHistory: $e") - // } - // } - - // def delete(annotationId: String) = { - // DatabaseConnection.db.run( - // TableQuery[PresAnnotationHistoryDbTableDef] - // .filter(_.annotationId === annotationId) - // .map(a => (a.annotationInfo)) - // .update("")) - // ).onComplete { - // case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) updated annotationInfo=null on PresAnnotationHistory table!") - // case Failure(e) => DatabaseConnection.logger.debug(s"Error updating annotationInfo=null PresAnnotationHistory: $e") - // } - // } - } \ No newline at end of file diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPageDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPageDAO.scala index 510e140e7d..37058a8434 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPageDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPageDAO.scala @@ -1,6 +1,5 @@ package org.bigbluebutton.core.db -import org.bigbluebutton.common2.msgs.AnnotationVO import org.bigbluebutton.core.models.PresentationInPod import slick.jdbc.PostgresProfile.api._ @@ -29,18 +28,13 @@ class PresPageDbTableDef(tag: Tag) extends Table[PresPageDbModel](tag, None, "pr val yOffset = column[Double]("yOffset") val widthRatio = column[Double]("widthRatio") val heightRatio = column[Double]("heightRatio") - // val presentation = foreignKey("presentation_fk", presentationId, Presentations)(_.presentationId, onDelete = ForeignKeyAction.Cascade) def * = (pageId, presentationId, num, urls, current, xOffset, yOffset, widthRatio, heightRatio) <> (PresPageDbModel.tupled, PresPageDbModel.unapply) } object PresPageDAO { - // def setCurrentPage(wbId: String, userId: String, annotationId: String) = { def setCurrentPage(presentation: PresentationInPod, pageId: String) = { - - // val updateSql = - DatabaseConnection.db.run( sqlu"""UPDATE pres_page SET "current" = (case when "pageId" = ${pageId} then true else false end) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPresentationDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPresentationDAO.scala index cf6a4317d9..1ed6160468 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPresentationDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresPresentationDAO.scala @@ -6,7 +6,6 @@ import org.bigbluebutton.core.models.{ PresentationInPod } import scala.concurrent.ExecutionContext.Implicits.global import scala.util.{ Failure, Success } import spray.json._ -//import DefaultJsonProtocol._ case class PresPresentationDbModel(presentationId: String, meetingId: String, current: Boolean, downloadable: Boolean, removable: Boolean) @@ -16,7 +15,6 @@ class PresPresentationDbTableDef(tag: Tag) extends Table[PresPresentationDbModel val current = column[Boolean]("current") val downloadable = column[Boolean]("downloadable") val removable = column[Boolean]("removable") - // val meeting = foreignKey("meeting_fk", meetingId, Meetings)(_.meetingId, onDelete = ForeignKeyAction.Cascade) def * = (presentationId, meetingId, current, downloadable, removable) <> (PresPresentationDbModel.tupled, PresPresentationDbModel.unapply) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserDAO.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserDAO.scala index eb56a81da0..61b8c86549 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserDAO.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserDAO.scala @@ -67,8 +67,6 @@ class UserDbTableDef(tag: Tag) extends Table[UserDbModel](tag, None, "user") { } object UserDAO { - // val usersTable = TableQuery[UserTableDef] - def insert(meetingId: String, regUser: RegisteredUser) = { DatabaseConnection.db.run( TableQuery[UserDbTableDef].forceInsert( @@ -126,17 +124,6 @@ object UserDAO { } } -// def delete(regUser: RegisteredUser) = { -// DatabaseConnection.db.run( -// TableQuery[UserDbTableDef] -// .filter(_.userId === regUser.id) -// .delete -// ).onComplete { -// case Success(rowsAffected) => DatabaseConnection.logger.debug(s"User ${regUser.id} deleted") -// case Failure(e) => DatabaseConnection.logger.debug(s"Error deleting user ${regUser.id}: $e") -// } -// } - def delete(intId: String) = { // DatabaseConnection.db.run( // TableQuery[UserDbTableDef] @@ -169,14 +156,5 @@ object UserDAO { } } -// def insert(user: UserDbModel) = { -// DatabaseConnection.db.run( -// TableQuery[UserDbTableDef].forceInsert(user) -// ).onComplete { -// case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) updated") -// case Failure(e) => DatabaseConnection.logger.debug(s"Error updating user: $e") -// } -// } - } 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 1edebf7a87..251af3b312 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 @@ -50,8 +50,6 @@ class UserVoiceDbTableDef(tag: Tag) extends Table[UserVoiceDbModel](tag, None, " object UserVoiceDAO { - // val usersTable = TableQuery[UserTableDef] - def insert(voiceUserState: VoiceUserState) = { DatabaseConnection.db.run( TableQuery[UserVoiceDbTableDef].insertOrUpdate( @@ -95,7 +93,6 @@ object UserVoiceDAO { } def updateTalking(voiceUserState: VoiceUserState) = { -// DatabaseConnection.db.run(sql"SELECT * FROM $users".as[(Int, Double, String)]).onComplete { val now = System.currentTimeMillis() val updateSql = if(voiceUserState.talking) { diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala index 206c41428e..4cc493f96d 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala @@ -27,7 +27,7 @@ object Users2x { } def remove(users: Users2x, intId: String): Option[UserState] = { - UserDAO.delete(intId) //TODO maybe just flag online=false, instead of delete + UserDAO.delete(intId) users.remove(intId) } @@ -124,7 +124,7 @@ object Users2x { _ <- users.remove(intId) ejectedUser <- users.removeFromCache(intId) } yield { - UserDAO.delete(intId) //TODO maybe just flag online=false, instead of delete + UserDAO.delete(intId) ejectedUser } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/util/RandomStringGenerator.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/util/RandomStringGenerator.scala index b1b60cc715..f2e0c92168 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/util/RandomStringGenerator.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/util/RandomStringGenerator.scala @@ -13,5 +13,12 @@ object RandomStringGenerator { // Generate a random alphabnumeric string of length n def randomAlphanumericString(n: Int) = randomString("abcdefghijklmnopqrstuvwxyz0123456789")(n) + + def randomColor = { + val colorOptions = List("#7b1fa2", "#6a1b9a", "#4a148c", "#5e35b1", "#512da8", "#4527a0", "#311b92", + "#3949ab", "#303f9f", "#283593", "#1a237e", "#1976d2", "#1565c0", "#0d47a1", "#0277bd", "#01579b") + colorOptions(random.nextInt(colorOptions.length)) + } + }