@@ -114,18 +114,19 @@ public com.taba.friendship.dto.AddFriendResponse addFriend(String inviteCode) {
114114 code .use (currentUser );
115115 inviteCodeRepository .save (code );
116116
117- // 친구 추가 알림 전송 (초대 코드를 사용한 사용자에게 알림)
118- String userLanguage = currentUser .getLanguage () != null ? currentUser .getLanguage () : "ko" ;
117+ // 친구 추가 알림 전송 (초대 코드를 받은 사용자에게 알림)
118+ // 친구를 추가한 사람이 아닌, 상대방에게 알림을 보냅니다
119+ String friendLanguage = freshFriendUser .getLanguage () != null ? freshFriendUser .getLanguage () : "ko" ;
119120 String title = com .taba .common .util .MessageUtil .getMessage (
120- "notification.friend.added.title" , userLanguage , freshFriendUser .getNickname ());
121+ "notification.friend.added.title" , friendLanguage , currentUser .getNickname ());
121122 String body = com .taba .common .util .MessageUtil .getMessage (
122- "notification.friend.added.body" , userLanguage );
123+ "notification.friend.added.body" , friendLanguage );
123124 notificationService .createAndSendNotification (
124- currentUser ,
125+ freshFriendUser ,
125126 title ,
126127 body ,
127128 com .taba .notification .entity .Notification .NotificationCategory .FRIEND ,
128- freshFriendUser .getId ()
129+ currentUser .getId ()
129130 );
130131
131132 // 친구 정보 반환 (최신 데이터 사용)
@@ -385,22 +386,9 @@ public void addFriendByUserIds(String userId1, String userId2) {
385386 .build ();
386387 friendshipRepository .save (friendship2 );
387388
388- // 친구 추가 알림 전송 (양쪽 사용자에게 알림)
389- // user1에게 알림
390- String user1Language = freshUser1 .getLanguage () != null ? freshUser1 .getLanguage () : "ko" ;
391- String title1 = com .taba .common .util .MessageUtil .getMessage (
392- "notification.friend.added.title" , user1Language , freshUser2 .getNickname ());
393- String body1 = com .taba .common .util .MessageUtil .getMessage (
394- "notification.friend.added.body" , user1Language );
395- notificationService .createAndSendNotification (
396- freshUser1 ,
397- title1 ,
398- body1 ,
399- com .taba .notification .entity .Notification .NotificationCategory .FRIEND ,
400- freshUser2 .getId ()
401- );
402-
403- // user2에게 알림
389+ // 친구 추가 알림 전송 (상대방에게만 알림)
390+ // 편지 답장 시 자동 친구 추가인 경우, 답장을 보낸 사람은 이미 편지 알림을 받았으므로
391+ // 친구 추가 알림은 상대방(user2)에게만 보냅니다
404392 String user2Language = freshUser2 .getLanguage () != null ? freshUser2 .getLanguage () : "ko" ;
405393 String title2 = com .taba .common .util .MessageUtil .getMessage (
406394 "notification.friend.added.title" , user2Language , freshUser1 .getNickname ());
0 commit comments