@@ -354,6 +354,8 @@ public QuestionResDTO.CommentUpdateDeleteRes updateComment(
354354
355355 comment .updateContent (request .getContent ());
356356
357+ publishCommentUpdatedEventAfterCommit (comment .getQuestion ());
358+
357359 return new QuestionResDTO .CommentUpdateDeleteRes (
358360 comment .getId (), comment .getContent (),
359361 comment .getUpdatedAt (), comment .getDeletedAt ()
@@ -369,6 +371,8 @@ public QuestionResDTO.CommentUpdateDeleteRes deleteComment(Long commentId, Long
369371
370372 comment .softDelete ();
371373
374+ publishCommentUpdatedEventAfterCommit (comment .getQuestion ());
375+
372376 return new QuestionResDTO .CommentUpdateDeleteRes (
373377 comment .getId (), comment .getContent (),
374378 comment .getUpdatedAt (), comment .getDeletedAt ()
@@ -751,6 +755,32 @@ private void publishCommentCreatedEventAfterCommit(Question question) {
751755 publishAfterCommit (() -> questionEventService .publishCommentCreated (sessionId , event ));
752756 }
753757
758+ private void publishCommentUpdatedEventAfterCommit (Question question ) {
759+ Long sessionId = question .getSession ().getId ();
760+ Long questionId = question .getId ();
761+ List <Long > questionIds = List .of (questionId );
762+
763+ Map <Long , Integer > commentCounts = new HashMap <>();
764+ questionCommentRepository .countByQuestionIds (questionIds )
765+ .forEach (row -> commentCounts .put (row .getQuestionId (), Math .toIntExact (row .getCommentCount ())));
766+
767+ Map <Long , List <QuestionResDTO .PreviewCommentResponse >> previewComments = new HashMap <>();
768+ questionCommentRepository .findPreviewCommentsByQuestionIds (questionIds )
769+ .forEach (row -> previewComments .computeIfAbsent (row .getQuestionId (), key -> new ArrayList <>())
770+ .add (toPreviewCommentResponse (question , row )));
771+
772+ QuestionResDTO .CommentUpdatedEvent event = new QuestionResDTO .CommentUpdatedEvent (
773+ "COMMENT_UPDATED" ,
774+ sessionId ,
775+ questionId ,
776+ question .getIsResolved (),
777+ commentCounts .getOrDefault (questionId , 0 ),
778+ previewComments .getOrDefault (questionId , List .of ())
779+ );
780+
781+ publishAfterCommit (() -> questionEventService .publishCommentUpdated (sessionId , event ));
782+ }
783+
754784 private void publishQuestionCreatedEventAfterCommit (Question question ) {
755785 Long sessionId = question .getSession ().getId ();
756786
0 commit comments