-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
채팅 알림 버그픽스 #687
Merged
Merged
채팅 알림 버그픽스 #687
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
43fd7bb
refactor: 모임 정보 수정시 알림 메시지에서 수정 전 모임 이름을 사용하도록 수정
pricelees 8ff90ec
refactor: 채팅 알림 구현 방법 및 메시지 형식 수정
pricelees 17ee186
refactor: 채팅 알림 메시지 세분화
pricelees 625004e
refactor: 모임에서의 다락방 조회 예외 메시지 추가
pricelees 44a4c0a
fix: 모임 ID 대신 다락방 ID를 사용하는 오타 수정
pricelees 68f15fa
refactor: 참여자가 입력된 DarakbangMember인지 확인하는 메서드 추가
pricelees 7e93055
refactor: memberId 필드 추가에 따른 Author 필드명 세분화(id -> darakbangMember)
pricelees f883d4f
refactor: Recipient 필드 final 지정 및 빌더 추가
pricelees b491a91
refactor: CommentRecipient를 Map을 가진 일급 컬렉션으로 수정
pricelees ac98c87
refactor: ChatDateTimeFormatter 세분화
pricelees aa86f72
fix: DateTimeFormatter 사용 제거
pricelees 325112c
Merge branch 'develop-backend' into fix/#684
pricelees File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
|
||
import mouda.backend.common.config.UrlConfig; | ||
import mouda.backend.darakbang.domain.Darakbang; | ||
import mouda.backend.darakbang.exception.DarakbangErrorMessage; | ||
import mouda.backend.darakbang.exception.DarakbangException; | ||
import mouda.backend.darakbang.infrastructure.DarakbangRepository; | ||
import mouda.backend.darakbangmember.domain.DarakbangMember; | ||
import mouda.backend.moim.domain.Moim; | ||
|
@@ -36,50 +38,58 @@ public MoimNotificationSender(UrlConfig urlConfig, ApplicationEventPublisher eve | |
public void sendMoimCreatedNotification(Moim moim, DarakbangMember author, NotificationType notificationType) { | ||
List<Recipient> recipients = moimRecipientFinder.getMoimCreatedNotificationRecipients(moim.getDarakbangId(), | ||
author.getId()); | ||
Darakbang darakbang = darakbangRepository.findById(moim.getDarakbangId()) | ||
.orElseThrow(IllegalArgumentException::new); | ||
NotificationEvent notificationEvent = NotificationEvent.nonChatEvent( | ||
notificationType, | ||
darakbang.getName(), | ||
MoimNotificationMessage.create(moim.getTitle(), notificationType), | ||
getMoimUrl(darakbang.getId(), moim.getId()), | ||
recipients | ||
); | ||
eventPublisher.publishEvent(notificationEvent); | ||
String message = MoimNotificationMessage.create(moim.getTitle(), notificationType); | ||
|
||
createEventAndPublish(notificationType, moim, message, recipients); | ||
} | ||
|
||
public void sendMoimStatusChangedNotification(Moim moim, NotificationType notificationType) { | ||
List<Recipient> recipients = moimRecipientFinder.getMoimStatusChangedNotificationRecipients(moim.getId()); | ||
String message = MoimNotificationMessage.create(moim.getTitle(), notificationType); | ||
sendMoimModifiedNotification(moim, notificationType, message); | ||
} | ||
|
||
public void sendMoimInfoModifiedNotification(Moim moim, String oldTitle, NotificationType notificationType) { | ||
String message = MoimNotificationMessage.create(oldTitle, notificationType); | ||
sendMoimModifiedNotification(moim, notificationType, message); | ||
} | ||
|
||
private void sendMoimModifiedNotification(Moim moim, NotificationType notificationType, String message) { | ||
List<Recipient> recipients = moimRecipientFinder.getMoimModifiedNotificationRecipients(moim.getId()); | ||
createEventAndPublish(notificationType, moim, message, recipients); | ||
} | ||
|
||
private void createEventAndPublish(NotificationType notificationType, Moim moim, String message, | ||
List<Recipient> recipients) { | ||
Darakbang darakbang = darakbangRepository.findById(moim.getDarakbangId()) | ||
.orElseThrow(IllegalArgumentException::new); | ||
.orElseThrow(() -> new DarakbangException(HttpStatus.NOT_FOUND, DarakbangErrorMessage.DARAKBANG_NOT_FOUND)); | ||
|
||
NotificationEvent notificationEvent = NotificationEvent.nonChatEvent( | ||
notificationType, | ||
darakbang.getName(), | ||
MoimNotificationMessage.create(moim.getTitle(), notificationType), | ||
getMoimUrl(darakbang.getId(), moim.getId()), | ||
message, | ||
getMoimUrl(darakbang.getId(), darakbang.getId()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 두개 다 다락방 아이디 맞나여?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
아뇨 ㅋㅋ 감사용 ㅋㅋ |
||
recipients | ||
); | ||
|
||
eventPublisher.publishEvent(notificationEvent); | ||
} | ||
|
||
static class MoimNotificationMessage { | ||
|
||
public static String create(String moimName, NotificationType type) { | ||
public static String create(String moimTitle, NotificationType type) { | ||
if (type == NotificationType.MOIM_CREATED) { | ||
return moimName + " 모임이 만들어졌어요!"; | ||
return moimTitle + " 모임이 만들어졌어요!"; | ||
} | ||
if (type == NotificationType.MOIMING_COMPLETED) { | ||
return moimName + " 모집이 마감되었어요!"; | ||
return moimTitle + " 모집이 마감되었어요!"; | ||
} | ||
if (type == NotificationType.MOINING_REOPENED) { | ||
return moimName + " 모집이 재개되었어요!"; | ||
return moimTitle + " 모집이 재개되었어요!"; | ||
} | ||
if (type == NotificationType.MOIM_CANCELLED) { | ||
return moimName + " 모임이 취소되었어요!"; | ||
return moimTitle + " 모임이 취소되었어요!"; | ||
} | ||
if (type == NotificationType.MOIM_MODIFIED) { | ||
return moimName + " 모임 정보가 변경되었어요!"; | ||
return moimTitle + " 모임 정보가 변경되었어요!"; | ||
} | ||
throw new NotificationException( | ||
HttpStatus.BAD_REQUEST, NotificationErrorMessage.NOT_ALLOWED_NOTIFICATION_TYPE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package에 해당하는 예외를 던져주기로 했던 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 이유로 알림 타입에 대한 예외는 모임 에러를 사용했는데, 여기서는 좀 애매한 감이 있어서 다락방 예외를 사용했어요 ㅋㅋ 말씀주신대로 모임예외로 수정하고, 예외 메시지를 "모임에 해당되는 다락방을 찾을 수 없음" 으로 수정할게요 ~