Repository navigation
[Feat/#115] 행사·사물함·공지 즉시 알림 발송 #120
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18187ed
feat: 신청·공지 알림 이벤트 추가
tnals0924 b8fab50
feat: 행사 신청·취소 시 알림 이벤트 기록
tnals0924 64e1263
feat: 사물함 배정 시 알림 이벤트 기록
tnals0924 931c2db
feat: 공지 등록 시 알림 이벤트 기록
tnals0924 e471a0a
feat: 즉시 알림 이벤트 리스너 추가
tnals0924 0be040d
fix: 행사 신청 알림 이동 대상을 신청 ID로 변경
tnals0924 7b7ac96
fix: 행사 신청 취소 알림 이동 대상을 신청 ID로 변경
tnals0924 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
4 changes: 4 additions & 0 deletions
4
core/common/src/main/java/kr/ac/kookmin/stream/common/event/EventApplicationCanceled.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package kr.ac.kookmin.stream.common.event; | ||
|
|
||
| /** 회원이 행사 신청을 취소했다. 행사명은 알림 문구에 쓰려고 취소 시점의 값을 싣는다. */ | ||
| public record EventApplicationCanceled(Long memberId, Long eventId, Long applicationId, String eventTitle) implements DomainEvent {} |
4 changes: 4 additions & 0 deletions
4
core/common/src/main/java/kr/ac/kookmin/stream/common/event/EventApplied.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package kr.ac.kookmin.stream.common.event; | ||
|
|
||
| /** 회원이 행사를 신청했다. 행사명은 알림 문구에 쓰려고 신청 시점의 값을 싣는다. */ | ||
| public record EventApplied(Long memberId, Long eventId, Long applicationId, String eventTitle) implements DomainEvent {} |
4 changes: 4 additions & 0 deletions
4
core/common/src/main/java/kr/ac/kookmin/stream/common/event/LockerAssigned.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package kr.ac.kookmin.stream.common.event; | ||
|
|
||
| /** 회원이 사물함을 신청해 배정받았다. 신청과 배정이 동시에 일어난다. */ | ||
| public record LockerAssigned(Long memberId, Long lockerPeriodId) implements DomainEvent {} |
4 changes: 4 additions & 0 deletions
4
core/common/src/main/java/kr/ac/kookmin/stream/common/event/NoticeCreated.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package kr.ac.kookmin.stream.common.event; | ||
|
|
||
| /** 운영진이 새 공지를 등록했다. 공지는 저장하는 즉시 공개된다. */ | ||
| public record NoticeCreated(Long noticeId) implements DomainEvent {} |
This file contains hidden or 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 hidden or 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 hidden or 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
47 changes: 47 additions & 0 deletions
47
.../ac/kookmin/stream/member/domain/notification/service/impl/NotificationEventListener.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package kr.ac.kookmin.stream.member.domain.notification.service.impl; | ||
|
|
||
| import java.util.List; | ||
| import kr.ac.kookmin.stream.common.event.EventApplicationCanceled; | ||
| import kr.ac.kookmin.stream.common.event.EventApplied; | ||
| import kr.ac.kookmin.stream.common.event.LockerAssigned; | ||
| import kr.ac.kookmin.stream.common.event.NoticeCreated; | ||
| import kr.ac.kookmin.stream.member.domain.notification.domain.NotificationType; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.context.event.EventListener; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * 다른 도메인의 이벤트를 알림으로 바꾼다. 아웃박스 릴레이가 트랜잭션 밖에서 발행하므로 {@code @EventListener}로 받는다. | ||
| * 예외를 던지면 릴레이가 같은 이벤트를 다시 발행한다. | ||
| */ | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| class NotificationEventListener { | ||
|
|
||
| private final NotificationDispatcher notificationDispatcher; | ||
|
|
||
| // 신청·취소 알림은 누르면 신청 내역 상세로 가야 하므로 행사가 아니라 신청 ID를 대상으로 준다 | ||
| @EventListener | ||
| public void on(EventApplied event) { | ||
| notificationDispatcher.dispatch( | ||
| NotificationType.EVENT_APPLIED, List.of(event.eventTitle()), event.applicationId(), List.of(event.memberId())); | ||
| } | ||
|
|
||
| @EventListener | ||
| public void on(EventApplicationCanceled event) { | ||
| notificationDispatcher.dispatch( | ||
| NotificationType.EVENT_APPLICATION_CANCELED, List.of(event.eventTitle()), event.applicationId(), List.of(event.memberId())); | ||
| } | ||
|
|
||
| @EventListener | ||
| public void on(LockerAssigned event) { | ||
| notificationDispatcher.dispatch( | ||
| NotificationType.LOCKER_ASSIGNED, List.of(), event.lockerPeriodId(), List.of(event.memberId())); | ||
| } | ||
|
|
||
| // 공지는 활성 회원 전체에게 간다 | ||
| @EventListener | ||
| public void on(NoticeCreated event) { | ||
| notificationDispatcher.dispatchToAll(NotificationType.NOTICE_CREATED, List.of(), event.noticeId(), List.of()); | ||
| } | ||
| } | ||
This file contains hidden or 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.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: billilge/stream-server
Length of output: 20124
알림 재전달 시 중복 저장과 중복 발송을 방지해야 합니다.
NotificationEventListener는 재전달된 이벤트마다NotificationDispatcher.dispatchToAll(...)를 다시 호출합니다.NotificationDispatcher.send는 기존 알림을 조회하거나 중복 키를 확인하지 않고notificationRepository.saveAll(...)로 수신자별 알림을 다시 저장합니다. 저장 후 푸시도 다시 발송하므로, 동일한 이벤트가 재시도되면 알림함과 푸시가 중복될 수 있습니다.이벤트 식별자를 알림의 중복 방지 기준으로 전달하고, 알림 저장과 푸시 발송이 재전달에도 멱등적으로 동작하도록 수정해 주세요. 부분 발송 후 재시도되는 경우에도 이미 처리한 수신자를 다시 저장하거나 발송하지 않아야 합니다. 다른 세 핸들러에도 같은 기준을 적용해야 합니다.
🤖 Prompt for AI Agents
Source: Path instructions