@@ -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