From 686903a5292c541b458e2d885ee1190fd9f12736 Mon Sep 17 00:00:00 2001 From: Gustavo Trott Date: Wed, 8 Nov 2023 10:21:28 -0300 Subject: [PATCH 1/2] In LearningDashboard, convert Reactions to EmojiStatus --- .../redis/LearningDashboardActor.scala | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala index bdc12a78a4..1712286448 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala @@ -397,10 +397,33 @@ class LearningDashboardActor( user <- findUserByIntId(meeting, msg.body.userId) } yield { if (msg.body.reactionEmoji != "none") { - val updatedUser = user.copy(reactions = user.reactions :+ Emoji(msg.body.reactionEmoji)) - val updatedMeeting = meeting.copy(users = meeting.users + (updatedUser.userKey -> updatedUser)) + //Not considering flooding reactions, ignoring if same Emoji was sent in the last 30 seconds + val hasSameReactionInLast30Seconds = user.reactions.filter(r => { + System.currentTimeMillis() - r.sentOn < (30 * 1000) && r.name == msg.body.reactionEmoji + }).length > 0 - meetings += (updatedMeeting.intId -> updatedMeeting) + if(!hasSameReactionInLast30Seconds) { + val updatedUser = user.copy(reactions = user.reactions :+ Emoji(msg.body.reactionEmoji)) + val updatedMeeting = meeting.copy(users = meeting.users + (updatedUser.userKey -> updatedUser)) + meetings += (updatedMeeting.intId -> updatedMeeting) + + //Convert Reactions to legacy Emoji (while LearningDashboard doesn't support Reactions) + val emoji = msg.body.reactionEmoji.codePointAt(0) match { + case 128515 => "happy" + case 128528 => "neutral" + case 128577 => "sad" + case 128077 => "thumbsUp" + case 128078 => "thumbsDown" + case 128079 => "applause" + case _ => "none" + } + + if (emoji != "none") { + val updatedUserWithEmoji = updatedUser.copy(emojis = user.emojis :+ Emoji(emoji)) + val updatedMeetingWithEmoji = meeting.copy(users = meeting.users + (updatedUserWithEmoji.userKey -> updatedUserWithEmoji)) + meetings += (updatedMeeting.intId -> updatedMeetingWithEmoji) + } + } } } } From 8b4b2266037d19769659fa0b2be2a6c5eeb38e98 Mon Sep 17 00:00:00 2001 From: Gustavo Trott Date: Wed, 8 Nov 2023 10:30:51 -0300 Subject: [PATCH 2/2] Improve comment to prevent flood --- .../bigbluebutton/endpoint/redis/LearningDashboardActor.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala index 1712286448..63ded0f632 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala @@ -397,7 +397,7 @@ class LearningDashboardActor( user <- findUserByIntId(meeting, msg.body.userId) } yield { if (msg.body.reactionEmoji != "none") { - //Not considering flooding reactions, ignoring if same Emoji was sent in the last 30 seconds + //Ignore multiple Reactions to prevent flooding val hasSameReactionInLast30Seconds = user.reactions.filter(r => { System.currentTimeMillis() - r.sentOn < (30 * 1000) && r.name == msg.body.reactionEmoji }).length > 0