Skip to content

Commit

Permalink
Merge pull request bigbluebutton#18842 from gustavotrott/graphql-bkro…
Browse files Browse the repository at this point in the history
…om-msg

refactor (graphql-server): Adds new chat msg type 'breakoutRoomModeratorMsg'
  • Loading branch information
gustavotrott authored Sep 25, 2023
2 parents 461a1c3 + afb1801 commit 49d60f6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bigbluebutton.core.apps.breakout

import org.bigbluebutton.common2.msgs.{ GroupChatAccess, GroupChatMsgFromUser }
import org.bigbluebutton.common2.msgs.{ GroupChatAccess, GroupChatMessageType, GroupChatMsgFromUser }
import org.bigbluebutton.core.api.SendMessageToBreakoutRoomInternalMsg
import org.bigbluebutton.core.apps.groupchats.GroupChatApp
import org.bigbluebutton.core.bus.MessageBus
Expand All @@ -20,7 +20,7 @@ trait SendMessageToBreakoutRoomInternalMsgHdlr {
} yield {
val groupChatMsgFromUser = GroupChatMsgFromUser(sender.id, sender.copy(name = msg.senderName), true, msg.msg)
val gcm = GroupChatApp.toGroupChatMessage(sender.copy(name = msg.senderName), groupChatMsgFromUser)
val gcs = GroupChatApp.addGroupChatMessage(liveMeeting.props.meetingProp.intId, chat, state.groupChats, gcm)
val gcs = GroupChatApp.addGroupChatMessage(liveMeeting.props.meetingProp.intId, chat, state.groupChats, gcm, GroupChatMessageType.BREAKOUTROOM_MOD_MSG)

val event = buildGroupChatMessageBroadcastEvtMsg(
liveMeeting.props.meetingProp.intId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait ClearPublicChatHistoryPubMsgHdlr extends LogHelper with RightsManagementTr
gc <- state.groupChats.find(msg.body.chatId)
} yield {
ChatMessageDAO.deleteAllFromChat(liveMeeting.props.meetingProp.intId, msg.body.chatId)
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, msg.body.chatId, "", "publicChatHistoryCleared", Map(), "")
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, msg.body.chatId, "", GroupChatMessageType.PUBLIC_CHAT_HIST_CLEARED, Map(), "")
broadcastEvent(msg)
val newGc = gc.clearMessages()
val gcs = state.groupChats.update(newGc)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.bigbluebutton.core.apps.groupchats

import org.bigbluebutton.common2.msgs.{ GroupChatAccess, GroupChatMsgFromUser, GroupChatMsgToUser, GroupChatUser }
import org.bigbluebutton.common2.msgs.{ GroupChatAccess, GroupChatMessageType, GroupChatMsgFromUser, GroupChatMsgToUser, GroupChatUser }
import org.bigbluebutton.core.db.ChatMessageDAO
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.models._
Expand Down Expand Up @@ -32,9 +32,9 @@ object GroupChatApp {
}

def addGroupChatMessage(meetingId: String, chat: GroupChat, chats: GroupChats,
msg: GroupChatMessage): GroupChats = {
msg: GroupChatMessage, messageType: String = GroupChatMessageType.DEFAULT): GroupChats = {
if (msg.sender.id == SystemUser.ID) {
ChatMessageDAO.insertSystemMsg(meetingId, chat.id, msg.message, "default", Map(), msg.sender.name)
ChatMessageDAO.insertSystemMsg(meetingId, chat.id, msg.message, messageType, Map(), msg.sender.name)
} else {
ChatMessageDAO.insert(meetingId, chat.id, msg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ trait ShowPollResultReqMsgHdlr extends RightsManagementTrait {
"numResponders" -> result.numResponders,
)

ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", "poll", resultAsSimpleMap, "")
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", GroupChatMessageType.POLL, resultAsSimpleMap, "")
broadcastEvent(msg, result, annotationProp)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
"fileURI" -> m.body.annotatedFileURI,
"filename" -> "annotated_slides.pdf"
)
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", "presentation", presentationDownloadInfo, "")
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", GroupChatMessageType.PRESENTATION, presentationDownloadInfo, "")
}

bus.outGW.send(buildBroadcastNewPresFileAvailable(m, liveMeeting))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ object GroupChatAccess {
val PRIVATE = "PRIVATE_ACCESS"
}

object GroupChatMessageType {
val DEFAULT = "default"
val PRESENTATION = "presentation"
val POLL = "poll"
val BREAKOUTROOM_MOD_MSG = "breakoutRoomModeratorMsg"
val PUBLIC_CHAT_HIST_CLEARED = "publicChatHistoryCleared"
}

case class GroupChatUser(id: String, name: String = "", role: String = "VIEWER")
case class GroupChatMsgFromUser(correlationId: String, sender: GroupChatUser, chatEmphasizedText: Boolean = false, message: String)
case class GroupChatMsgToUser(id: String, timestamp: Long, correlationId: String, sender: GroupChatUser, chatEmphasizedText: Boolean = false, message: String)
Expand Down

0 comments on commit 49d60f6

Please sign in to comment.