@@ -77,25 +77,20 @@ public InvitationResponseDTO.createInvitation createInvitation(User user, Invita
77
77
Member sender = memberQueryAdapter .findByUserAndTreehouse (user , treehouse );
78
78
// 초대 대상이 가입된 사람인지 찾기
79
79
80
- User receiverUser = null ;
80
+ User receiverUser = userQueryAdapter . findByPhoneNumberOptional ( request . getPhoneNumber ()). orElse ( null ) ;
81
81
82
- try {
83
- receiverUser = userQueryAdapter .findByPhoneNumber (request .getPhoneNumber ());
84
- }
85
- catch (UserException e ){
86
- // 뭐 안함
87
- }
88
82
// 초대장 만들어서 저장하기
89
83
90
84
Invitation invitation = invitationCommandAdapter .saveInvitation (InvitationMapper .toInvitation (request .getPhoneNumber (), sender , receiverUser , treehouse ));
91
85
92
86
//알림 생성
93
- NotificationRequestDTO .createNotification notificationRequest = new NotificationRequestDTO .createNotification ();
94
- notificationRequest .setReceiverId (receiverUser .getId ()); // 여기서 receiver 설정 (예시)
95
- notificationRequest .setTargetId (invitation .getId ());
96
- notificationRequest .setType (NotificationType .INVITATION ); // 알림 타입 설정 (예시)
97
- notificationService .createNotification (user , invitation .getTreeHouse ().getId (), notificationRequest , null );
98
-
87
+ if (receiverUser != null ) {
88
+ NotificationRequestDTO .createNotification notificationRequest = new NotificationRequestDTO .createNotification ();
89
+ notificationRequest .setReceiverId (receiverUser .getId ()); // 여기서 receiver 설정 (예시)
90
+ notificationRequest .setTargetId (invitation .getId ());
91
+ notificationRequest .setType (NotificationType .INVITATION ); // 알림 타입 설정 (예시)
92
+ notificationService .createNotification (user , invitation .getTreeHouse ().getId (), notificationRequest , null );
93
+ }
99
94
// 리턴하기
100
95
101
96
return InvitationMapper .toCreateInvitationDTO (invitation );
0 commit comments