Repository navigation
Conversation
PermissionsPolicyTest checks permissions.json against every request the controllers answer. The reaction routes for direct messages and group chats go with the other /api/dm and /api/groups/chat requests: any signed-in admin, student, teacher or user, as the filter chain answers today.
…se group ids A remove read the row and then deleted it, so a second remove at the same moment could fail. Removing one reaction and clearing a deleted message's reactions are now single delete statements. The names of the people who reacted come from one query for id, uid and name, instead of whole Person rows that also loaded each person's eager links. A group message id has to be a lowercase UUID, like the ids Spring saves, so an uppercase copy can't match some lookups and miss others on MySQL.
…in then The frame was sent inside the change's transaction with the reactions read there, so two people reacting at the same moment could each send a list missing the other's reaction, and everyone in the chat would keep one of them. It is now sent once the transaction commits, with the reactions read in a transaction of their own. A group's reactions were already read after their change had committed.
Spring still starts, as it does when the calls or calendar tables can't be made, but the log now says reactions won't work instead of a warning that is easy to miss.
The group chat fixes (Open-Coding-Society#296 to Open-Coding-Society#299) each add a line after the chat regression tests, so the reactions line goes above it and the two change different places.
svaka2000
added a commit
to svaka2000/Spring-JJ
that referenced
this pull request
Nov 26, 2026
…or's types GroupChatSendTest built GroupChatApiController, GroupChatRealtimeService and GroupChatReadService by naming their constructors. Open PRs add constructor dependencies to the controller and the realtime service (Open-Coding-Society#302 a MessageReactionService, Open-Coding-Society#303 a MentorAccess), so once one of them and this test were both on master, the tests would stop compiling, with no merge conflict to show it. TestBeans builds a class through its biggest constructor: each parameter gets the first object the test passes that fits it, and a Mockito mock otherwise. The test then keeps compiling and running whatever dependencies those classes gain.
Contributor
Author
|
Combined into #314 with the same commits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
People can react to a message in a DM or a group chat with one of six emoji: like, love, haha, wow, sad and celebrate. This is the backend half. The frontend half is a separate PR on the pages repo, and it needs this one deployed first.
message_reactiontable in a newmvc/reactionspackage, with one row for each person, message and reaction.MessageReactionTableInitializercreates the table at startup if it's missing. If that fails, Spring still starts, like it does for the other tables, and the log shows an error saying reactions won't work.Reactionis an enum of the six keys. Spring stores the key, not the emoji, and an unknown key answers 400.GET /api/dm/conversations/{id}/reactionsgives the reactions on every message in the conversation.PUTorDELETE /api/dm/conversations/{id}/messages/{messageId}/reactions/{reaction}adds or takes back yours and answers with that message's reactions. Only the conversation's two people can use them (403 for anyone else, 404 if the conversation doesn't exist). The message has to be in that conversation (404), and a deleted message can't get one (409)./api/groups/chat/{groupId}. They follow the group chat's own rule: any signed-in account, with no membership check, same as reading and posting on master.reactionsServerframe, and DMs send one withtype: "reactions". A DM's frame goes out once the change is saved, with the reactions read again then, so two people reacting at the same moment both show up.Other notes:
src/main/resources/data/permissions.json, next to the other/api/dmand/api/groups/chatrequests, soPermissionsPolicyTestpasses.docs/group-chat-architecture.mdand added them toapi/groups.http.GroupChatSendTest, which buildsGroupChatApiControllerandGroupChatRealtimeServicewithout the reaction service. Once both are in, those two calls each needmock(MessageReactionService.class)as a last argument, or the tests won't compile and the Dockerfile's./mvnw packagestops. Whichever lands second adds it, and if they land first I'll add it here.GroupChatApiControllerand its two tests, so they conflict in a few small hunks where both arguments stay. Whichever merges second also puts Mentors: no direct messages, and only the groups they're added to #303's mentor check on the reaction routes, and if Mentors: no direct messages, and only the groups they're added to #303 merges first, I'll do that here.ReactionTest,MessageReactionTableInitializerTest,MessageReactionServiceTest,DirectMessageReactionTestandGroupChatReactionTest(31 tests). I also ran the full suite:ImportPersonPasswordTest(it needs a local.env) andPersonCapstoneApprovalRouteTestfail, and both fail the same way on master.How to try it: run
./mvnw test -Dtest='*Reaction*Test,PermissionsPolicyTest'. To try it by hand, start Spring and send the new requests inapi/groups.http: PUT a reaction, then GET the group's reactions.