@@ -136,4 +136,55 @@ public void testActivityModeratedReactions() throws Exception {
136136 assertEquals (m .getStatus (), "complete" );
137137 assertEquals (m .getRecommendedAction (), "remove" );
138138 }
139+
140+ @ Test
141+ public void testReactionModerationDuringUpdate () throws Exception {
142+ // Create a test activity first
143+ Activity activity = Activity .builder ()
144+ .actor ("test-user" )
145+ .verb ("post" )
146+ .object ("test-object" )
147+ .build ();
148+
149+ // Add the activity to a test feed
150+ Activity createdActivity = client .flatFeed ("user" , "test-user" ).addActivity (activity ).join ();
151+ String activityId = createdActivity .getID ();
152+
153+ // Create initial reaction with safe text
154+ Reaction initialReaction = Reaction .builder ()
155+ .activityID (activityId )
156+ .kind ("comment" )
157+ .userID ("test-user" )
158+ .extraField ("text" , "This is a perfectly fine comment" )
159+ .moderationTemplate ("moderation_template_reaction" )
160+ .build ();
161+
162+ // Add reaction and verify it passes moderation
163+ Reaction createdReaction = client .reactions ().add ("test-user" , initialReaction ).join ();
164+ ModerationResponse initialModeration = createdReaction .getModerationResponse ();
165+ assertEquals ("keep" , initialModeration .getRecommendedAction ());
166+
167+ // Now update the reaction with text that should trigger moderation
168+ Reaction updateData = Reaction .builder ()
169+ .id (createdReaction .getId ())
170+ .kind ("comment" )
171+ .extraField ("text" , "pissoar" ) // Using same blocked word as in testActivityModeratedReactions
172+ .moderationTemplate ("moderation_template_reaction" )
173+ .build ();
174+
175+ // Update the reaction
176+ client .reactions ().update (updateData ).join ();
177+
178+ // Fetch the updated reaction and verify moderation was applied
179+ Reaction updatedReaction = client .reactions ().get (createdReaction .getId ()).join ();
180+ ModerationResponse updatedModeration = updatedReaction .getModerationResponse ();
181+
182+ // With our fix to include moderation_template in updates, this should now be "remove"
183+ assertEquals ("complete" , updatedModeration .getStatus ());
184+ assertEquals ("remove" , updatedModeration .getRecommendedAction ());
185+
186+ // Clean up
187+ client .reactions ().delete (createdReaction .getId (), false ).join ();
188+ client .flatFeed ("user" , "test-user" ).removeActivityByID (activityId ).join ();
189+ }
139190}
0 commit comments