Repository navigation
gql-server: Add props to enable a user to Reply a chat message (backend portion) - #21296
Conversation
replyToMessageId will be useful for the feature that enables to reply a message of the chat messageSequence will be useful to identify the page of that message and scroll the user to the correct page when they click to see the original message
This comment was marked as off-topic.
This comment was marked as off-topic.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (5)
bbb-graphql-actions/src/actions/chatSendMessage.ts (1)
35-35: LGTM:replyToMessageIdadded to message body, with a minor suggestion.The
replyToMessageIdhas been correctly added to the message body, using the input value if provided. This implementation aligns well with the PR objectives for supporting message replies.Consider using
nullinstead of an empty string as the default value forreplyToMessageId. This would more clearly indicate the absence of a reply:- replyToMessageId: input.replyToMessageId || "", + replyToMessageId: input.replyToMessageId || null,This change could make it easier to distinguish between messages without replies and those replying to a deleted message (which might retain an empty string ID).
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/SendMessageToBreakoutRoomInternalMsgHdlr.scala (1)
Line range hint
1-41: Consider improving documentation for the newreplyToMessageIdparameterWhile the code structure is clean and follows Scala best practices, it might be beneficial to add documentation explaining the purpose and future use of the
replyToMessageIdparameter. This would help other developers understand the intent behind this change and how it relates to the message reply feature.Consider adding a comment above the
GroupChatMsgFromUserinstantiation explaining the purpose of thereplyToMessageIdparameter and any future plans for its use in breakout rooms.bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/GroupChatMsg.scala (1)
20-26: LGTM! Consider adding documentation for the new field.The addition of the
replyToMessageIdfield to theGroupChatMsgFromUsercase class aligns well with the PR objectives of enabling message replies. The implementation looks correct and consistent with the existing structure.Consider adding a brief comment above the case class or the new field to explain its purpose and usage. For example:
/** * Represents a group chat message from a user. * @param replyToMessageId The ID of the message being replied to, if any. */ case class GroupChatMsgFromUser( // ... other fields ... replyToMessageId: String, // ID of the message being replied to (empty if not a reply) // ... other fields ... )This documentation will help other developers understand the purpose of the new field at a glance.
bbb-graphql-server/bbb_schema.sql (2)
987-987: LGTM: Message sequence implementation looks good.The addition of the
messageSequencecolumn and the corresponding trigger function is well-implemented. This change aligns with the PR objective of tracking the sequence of messages, which will help identify the page where the original message is located.Consider adding an index on the
messageSequencecolumn to improve query performance when retrieving messages in order:CREATE INDEX idx_chat_message_sequence ON chat_message(meetingId, chatId, messageSequence);This index will be particularly useful when implementing pagination or when fetching messages around a specific sequence number.
Also applies to: 1001-1017
1073-1077: LGTM: Private chat message view updated correctly.The
v_chat_message_privateview has been properly updated to include the newreplyToMessageIdcolumn. This change ensures that the reply information is available when querying private chat messages, supporting the new reply feature in the client application.Consider adding a join to the
chat_messagetable to include information about the replied-to message. This could be useful for displaying a preview of the original message in the client application:CREATE OR REPLACE VIEW "v_chat_message_private" AS SELECT cu."meetingId", cu."userId", cm."messageId", cm."chatId", cm."correlationId", cm."messageSequence", cm."chatEmphasizedText", cm."message", cm."messageType", cm."replyToMessageId", reply."message" AS "replyToMessage", reply."userId" AS "replyToUserId", cm."messageMetadata", cm."senderId", cm."senderName", cm."senderRole", cm."createdAt", CASE WHEN chat_with."lastSeenAt" >= cm."createdAt" THEN true ELSE false END "recipientHasSeen" FROM chat_message cm JOIN chat_user cu ON cu."meetingId" = cm."meetingId" AND cu."chatId" = cm."chatId" LEFT JOIN chat_message reply ON reply."messageId" = cm."replyToMessageId" LEFT JOIN "chat_user" chat_with ON chat_with."meetingId" = cm."meetingId" AND chat_with."chatId" = cm."chatId" AND chat_with."userId" != cu."userId" WHERE cm."chatId" != 'MAIN-PUBLIC-GROUP-CHAT';This change would provide more context for replied-to messages without requiring additional queries from the client.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (11)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/SendMessageToBreakoutRoomInternalMsgHdlr.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/GroupChat.scala (2 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageFromApiSysPubMsgHdlr.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/ChatMessageDAO.scala (4 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/GroupChats.scala (1 hunks)
- bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/GroupChatMsg.scala (1 hunks)
- bbb-graphql-actions/src/actions/chatSendMessage.ts (2 hunks)
- bbb-graphql-server/bbb_schema.sql (3 hunks)
- bbb-graphql-server/metadata/actions.graphql (1 hunks)
- bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_chat_message_private.yaml (2 hunks)
- bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_chat_message_public.yaml (2 hunks)
🔇 Additional comments (19)
bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_chat_message_public.yaml (3)
10-18: LGTM: New object relationship for message replies.The new
replyToMessageobject relationship is correctly configured to enable threaded conversations. It appropriately links thereplyToMessageIdto themessageIdwithin the same table, allowing for self-referential relationships between messages.
40-40: LGTM: AddedmessageSequenceto select permissions.The addition of the
messageSequencecolumn to the select permissions for thebbb_clientrole is appropriate. This change allows clients to access the new field, which is essential for identifying the page location of original messages in threaded conversations.
Line range hint
1-48: Summary: Enhancements to support message replies and sequencing.The changes to this configuration file successfully implement the backend portion of the chat reply feature. The new
replyToMessagerelationship enables threaded conversations, while the addition ofmessageSequenceto the select permissions allows clients to access this crucial information for message navigation.These modifications align well with the PR objectives and provide a solid foundation for the frontend implementation of the chat reply feature.
bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_chat_message_private.yaml (3)
10-18: LGTM: New object relationshipreplyToMessageadded correctly.The new object relationship
replyToMessageis correctly configured to enable message replies. It uses a manual configuration to mapreplyToMessageIdtomessageIdwithin the same table, which aligns with the PR objective of allowing users to reply to chat messages.
40-40: LGTM:messageSequencecolumn added to select permissions.The
messageSequencecolumn has been correctly added to the list of permitted columns for thebbb_clientrole. This change aligns with the PR objective of introducing a new field to track the sequence of messages, which will help identify the page where the original message is located.
Line range hint
10-40: Summary: Changes align well with PR objectives.The modifications to this configuration file effectively support the new message reply feature:
- The new
replyToMessageobject relationship enables referencing reply messages.- The addition of the
messageSequencecolumn to the select permissions allows clients to access the new field for message sequencing.These changes are consistent with the PR objectives and contribute to enhancing the chat functionality by enabling message replies and providing additional context for chat interactions.
bbb-graphql-actions/src/actions/chatSendMessage.ts (2)
9-9: LGTM: Input validation forreplyToMessageIdadded correctly.The new
replyToMessageIdparameter has been properly added to the input validation schema. It's correctly set as an optional string, which aligns with the PR objectives for implementing message replies.
Line range hint
1-42: Verify consistency with related components.The changes in this file successfully implement the backend portion of the reply functionality as described in the PR objectives. To ensure full compatibility:
Please run the following script to check if the GraphQL schema has been updated accordingly:
This will help confirm that the GraphQL schema has been updated to match these implementation changes.
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/SendMessageToBreakoutRoomInternalMsgHdlr.scala (1)
21-21: Addition ofreplyToMessageIdparameter aligns with PR objectivesThe change to include
replyToMessageId = ""in theGroupChatMsgFromUserconstructor aligns with the PR's objective of enabling message replies. However, initializing it with an empty string suggests that reply functionality might not be fully implemented for breakout rooms yet.To ensure consistency across the codebase, let's verify the usage of
GroupChatMsgFromUserin other files:✅ Verification successful
Verified consistency in
GroupChatMsgFromUserusageAll instances of
GroupChatMsgFromUseracross the codebase initializereplyToMessageIdwith an empty string, ensuring consistent usage. No issues found regarding the addition of thereplyToMessageIdparameter in the reviewed file.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for other occurrences of GroupChatMsgFromUser to ensure consistent usage of replyToMessageId # Test: Search for GroupChatMsgFromUser constructor calls rg --type scala -A 5 'GroupChatMsgFromUser\('Length of output: 4449
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/GroupChats.scala (1)
41-41: Approved: Addition ofreplyToMessageIdtoGroupChatMessageThe addition of
replyToMessageId: Stringto theGroupChatMessagecase class aligns well with the PR objective of implementing a reply feature for chat messages. This change provides the necessary structure to associate a reply with its original message.To ensure this change is implemented consistently across the codebase, please run the following script to verify the usage of
GroupChatMessage:Consider the following suggestions:
- Ensure that all places where
GroupChatMessageis instantiated are updated to include thereplyToMessageIdparameter.- For backward compatibility, you might want to provide a default value for
replyToMessageId, such as an empty string ornull. This would allow existing code to work without modification. For example:case class GroupChatMessage( // ... other fields ... message: String, replyToMessageId: String = "", // or = null metadata: Map[String, Any] = Map.empty )
- Update any serialization/deserialization logic for
GroupChatMessageto include the new field.- If there are any database schemas or APIs that represent this message structure, ensure they are also updated accordingly.
bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/GroupChatMsg.scala (2)
27-34: Formatting improvement looks good.The reformatting of the
GroupChatMsgToUsercase class enhances readability by aligning fields vertically. This change is purely cosmetic and doesn't affect functionality, which is appropriate given that the reply feature is primarily handled in theGroupChatMsgFromUserclass.
Line range hint
1-34: Summary: Changes align well with PR objectivesThe modifications to this file successfully implement the backend portion of the chat message reply feature. The addition of the
replyToMessageIdfield toGroupChatMsgFromUserenables the tracking of message replies, which is a key objective of this PR. The reformatting ofGroupChatMsgToUserimproves code readability without changing functionality.These changes lay the groundwork for the GraphQL mutations and subscriptions mentioned in the PR objectives. The next steps would likely involve implementing the actual GraphQL resolvers and subscriptions that utilize these updated message structures.
To ensure consistency across the codebase, let's verify the usage of these updated case classes:
This script will help identify any places where the updated
GroupChatMsgFromUsermight not have been properly implemented or whereGroupChatMsgToUsermight have been inadvertently modified.bbb-graphql-server/bbb_schema.sql (2)
986-991: LGTM: Chat message reply feature implemented correctly.The addition of the
replyToMessageIdcolumn to thechat_messagetable is well-implemented. It correctly references themessageIdcolumn, allowing for a hierarchical structure of messages. This change aligns with the PR objective of implementing a reply feature for chat messages.
Line range hint
1-1477: Overall, the changes look good and align with the PR objectives.The implementation of the chat reply feature and message sequence tracking in the database schema is well-done. The changes provide the necessary structure to support the new functionality described in the PR objectives. Here's a summary of the key points:
- The chat reply feature is correctly implemented with the addition of the
replyToMessageIdcolumn.- Message sequence tracking is added through the
messageSequencecolumn and associated trigger.- The
v_chat_message_privateview is updated to include the new reply information.The suggestions provided for adding an index on the
messageSequencecolumn and expanding thev_chat_message_privateview are optional optimizations that could enhance performance and functionality.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/GroupChat.scala (1)
26-26: LGTM!Passing
msg.replyToMessageIdtoGroupChatMessagecorrectly enables the message reply functionality.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/ChatMessageDAO.scala (4)
15-15: Addition ofreplyToMessageIdfield toChatMessageDbModelThe optional field
replyToMessageId: Option[String]is appropriately added to the data model to support message replies.
31-31: Definition ofreplyToMessageIdcolumn inChatMessageDbTableDefDefining
replyToMessageIdascolumn[Option[String]]("replyToMessageId")correctly reflects the new field in the database schema.
39-39: Inclusion ofreplyToMessageIdin the table projectionUpdating the
*projection to includereplyToMessageIdensures proper mapping between the database table and the data model.
103-103: SettingreplyToMessageIdtoNonefor system messagesAssigning
replyToMessageId = Nonefor system messages correctly indicates that system messages do not reply to any existing messages.
Automated tests Summary✅ All the CI tests have passed! |




Aiming to enable the implementation of the feature Reply Chat Message, this PR introduces new fields to Graphql:
Mutation to reply: