11package com .somemore .notification .converter ;
22
33import com .fasterxml .jackson .core .JsonProcessingException ;
4- import com .fasterxml .jackson .databind .JsonMappingException ;
54import com .fasterxml .jackson .databind .JsonNode ;
65import com .fasterxml .jackson .databind .ObjectMapper ;
6+ import com .somemore .community .event .CommentAddedEvent ;
77import com .somemore .facade .event .VolunteerReviewRequestEvent ;
88import com .somemore .notification .domain .Notification ;
99import com .somemore .notification .domain .NotificationSubType ;
@@ -29,6 +29,7 @@ public Notification from(String message) {
2929 case NOTE_BLAH_BLAH -> throw new UnsupportedOperationException ("NOTE 알림 타입 처리 로직 미구현" );
3030 case VOLUNTEER_REVIEW_REQUEST -> buildVolunteerReviewRequestNotification (message );
3131 case VOLUNTEER_APPLY_STATUS_CHANGE -> buildVolunteerApplyStatusChangeNotification (message );
32+ case COMMENT_ADDED -> buildCommentAddedNotification (message );
3233 };
3334 } catch (Exception e ) {
3435 log .error (e .getMessage ());
@@ -58,6 +59,17 @@ private Notification buildVolunteerApplyStatusChangeNotification(String message)
5859 .build ();
5960 }
6061
62+ private Notification buildCommentAddedNotification (String message ) throws JsonProcessingException {
63+ CommentAddedEvent event = objectMapper .readValue (message , CommentAddedEvent .class );
64+
65+ return Notification .builder ()
66+ .receiverId (event .getVolunteerId ())
67+ .title (createCommentAddedNotificationTitle ())
68+ .type (NotificationSubType .COMMENT_ADDED )
69+ .relatedId (event .getCommunityBoardId ())
70+ .build ();
71+ }
72+
6173 private String createVolunteerReviewRequestNotificationTitle () {
6274 return "최근 활동하신 활동의 후기를 작성해 주세요!" ;
6375 }
@@ -72,4 +84,8 @@ private String createVolunteerApplyStatusChangeNotificationTitle(ApplyStatus new
7284 }
7385 };
7486 }
87+
88+ private String createCommentAddedNotificationTitle () {
89+ return "새로운 댓글이 작성되었습니다." ;
90+ }
7591}
0 commit comments