Fix graphql with hard-coded reaction expire time

This commit is contained in:
Gustavo Trott 2023-12-13 17:46:37 -03:00
parent 7d1f2a9f18
commit 328906e44f
5 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package org.bigbluebutton.core.apps.users package org.bigbluebutton.core.apps.users
import org.bigbluebutton.ClientSettings.getConfigPropertyValueByPath
import org.bigbluebutton.common2.msgs._ import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.apps.RightsManagementTrait import org.bigbluebutton.core.apps.RightsManagementTrait
import org.bigbluebutton.core.models.{ UserState, Users2x } import org.bigbluebutton.core.models.{ UserState, Users2x }
@ -29,9 +30,17 @@ trait ChangeUserReactionEmojiReqMsgHdlr extends RightsManagementTrait {
outGW.send(msgEventChange) outGW.send(msgEventChange)
} }
//Get durationInSeconds from Client config
val userReactionExpire =
getConfigPropertyValueByPath(liveMeeting.clientSettings, "public.userReaction.expire") match {
case Some(durationInSeconds: Int) => durationInSeconds
case _ =>
log.debug("Config `public.userReaction.expire` not found.")
30
}
for { for {
user <- Users2x.findWithIntId(liveMeeting.users2x, msg.body.userId) user <- Users2x.findWithIntId(liveMeeting.users2x, msg.body.userId)
newUserState <- Users2x.setReactionEmoji(liveMeeting.users2x, user.intId, msg.body.reactionEmoji) newUserState <- Users2x.setReactionEmoji(liveMeeting.users2x, user.intId, msg.body.reactionEmoji, userReactionExpire)
} yield { } yield {
if (user.reactionEmoji != msg.body.reactionEmoji) { if (user.reactionEmoji != msg.body.reactionEmoji) {
broadcast(newUserState, msg.body.reactionEmoji) broadcast(newUserState, msg.body.reactionEmoji)

View File

@ -24,7 +24,7 @@ trait ClearAllUsersReactionCmdMsgHdlr extends RightsManagementTrait {
user <- Users2x.findAll(liveMeeting.users2x) user <- Users2x.findAll(liveMeeting.users2x)
} yield { } yield {
//Don't clear away and RaiseHand //Don't clear away and RaiseHand
Users2x.setReactionEmoji(liveMeeting.users2x, user.intId, "none") Users2x.setReactionEmoji(liveMeeting.users2x, user.intId, "none", 0)
} }
sendClearedAllUsersReactionEvtMsg(outGW, liveMeeting.props.meetingProp.intId, msg.header.userId) sendClearedAllUsersReactionEvtMsg(outGW, liveMeeting.props.meetingProp.intId, msg.header.userId)
} else { } else {

View File

@ -13,7 +13,7 @@ trait UserReactionTimeExpiredCmdMsgHdlr extends RightsManagementTrait {
def handleUserReactionTimeExpiredCmdMsg(msg: UserReactionTimeExpiredCmdMsg) { def handleUserReactionTimeExpiredCmdMsg(msg: UserReactionTimeExpiredCmdMsg) {
val isNodeUser = msg.header.userId.equals("nodeJSapp") val isNodeUser = msg.header.userId.equals("nodeJSapp")
if (isNodeUser) { if (isNodeUser) {
Users2x.setReactionEmoji(liveMeeting.users2x, msg.body.userId, "none") Users2x.setReactionEmoji(liveMeeting.users2x, msg.body.userId, "none", 0)
} }
} }
} }

View File

@ -23,13 +23,13 @@ class UserReactionDbTableDef(tag: Tag) extends Table[UserReactionDbModel](tag, "
} }
object UserReactionDAO { object UserReactionDAO {
def insert(userId: String, reactionEmoji: String) = { def insert(userId: String, reactionEmoji: String, durationInSeconds: Int) = {
DatabaseConnection.db.run( DatabaseConnection.db.run(
TableQuery[UserReactionDbTableDef].forceInsert( TableQuery[UserReactionDbTableDef].forceInsert(
UserReactionDbModel( UserReactionDbModel(
userId = userId, userId = userId,
reactionEmoji = reactionEmoji, reactionEmoji = reactionEmoji,
durationInSeconds = 60, durationInSeconds = durationInSeconds,
createdAt = new java.sql.Timestamp(System.currentTimeMillis()) createdAt = new java.sql.Timestamp(System.currentTimeMillis())
) )
) )

View File

@ -195,7 +195,7 @@ object Users2x {
newUser newUser
} }
} }
def setReactionEmoji(users: Users2x, intId: String, reactionEmoji: String): Option[UserState] = { def setReactionEmoji(users: Users2x, intId: String, reactionEmoji: String, durationInSeconds: Int): Option[UserState] = {
for { for {
u <- findWithIntId(users, intId) u <- findWithIntId(users, intId)
} yield { } yield {
@ -203,7 +203,7 @@ object Users2x {
.modify(_.reactionChangedOn).setTo(System.currentTimeMillis()) .modify(_.reactionChangedOn).setTo(System.currentTimeMillis())
users.save(newUser) users.save(newUser)
UserReactionDAO.insert(intId, reactionEmoji) UserReactionDAO.insert(intId, reactionEmoji, durationInSeconds)
newUser newUser
} }
} }