-
Notifications
You must be signed in to change notification settings - Fork 1
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
#106 [RESTRUCTURING] : 이벤트를 활용한 fcm push 알림 구현 #122
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a4250ea
#106 [RESTRUCTURING] : event를 이용해서 fcm push보내게 리스트럭쳐링
hye-on 80e1076
[CHORE] : 사용하지 않는 코드, 파일 삭제
hye-on 03d511d
[FIX] : 순환종속성 해결
hye-on 00a009b
Merge branch 'main' of https://github.com/Wake-up-together-TogetUp/to…
hye-on f4f9cf3
#106 [RESTRUCTURING] : 그룹알람을 이벤트로 fcm 알림 보내게 수정
hye-on 04b2077
#106 [FIX] : 이벤트리스너를 이벤트핸들러로 이름 수정
hye-on 05364bf
#123 [FIX] :리뷰반영. vo이름 변경
hye-on aa9dfac
#123 [FIX] :리뷰반영. EventPublisher정의
hye-on 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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/wakeUpTogetUp/togetUp/api/notification/NotificationEventHandler.java
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.wakeUpTogetUp.togetUp.api.notification; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.notification.vo.NotificationSendVo; | ||
import com.wakeUpTogetUp.togetUp.infra.fcm.FcmService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Component; | ||
|
||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NotificationEventHandler { | ||
private final FcmService fcmService; | ||
|
||
@Async() | ||
@EventListener(NotificationSendVo.class) | ||
public void handleSendPushEvent(NotificationSendVo event) { | ||
fcmService.sendMessageToTokens(event); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/wakeUpTogetUp/togetUp/api/notification/NotificationEventPublisher.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.wakeUpTogetUp.togetUp.api.notification; | ||
|
||
import com.wakeUpTogetUp.togetUp.api.notification.vo.NotificationSendVo; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class NotificationEventPublisher { | ||
private final ApplicationEventPublisher eventPublisher; | ||
|
||
public void publishNotificationSendEvent(NotificationSendVo notificationSendVo) { | ||
eventPublisher.publishEvent(notificationSendVo); | ||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
@Service | ||
|
||
@RequiredArgsConstructor | ||
public class PushLogService { | ||
public class NotificationLogService { | ||
|
||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/com/wakeUpTogetUp/togetUp/api/notification/NotificationProvider.java
This file was deleted.
Oops, something went wrong.
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
26 changes: 0 additions & 26 deletions
26
...ain/java/com/wakeUpTogetUp/togetUp/api/notification/dto/response/PushNotificationRes.java
This file was deleted.
Oops, something went wrong.
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/wakeUpTogetUp/togetUp/api/users/UserEventHandler.java
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.wakeUpTogetUp.togetUp.api.users; | ||
|
||
|
||
import com.wakeUpTogetUp.togetUp.api.users.fcmToken.FcmTokenDeleteEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
||
@Slf4j | ||
@Component | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class UserEventHandler { | ||
|
||
private final UserService userService; | ||
|
||
@EventListener(FcmTokenDeleteEvent.class) | ||
public void handlePushTokenDeleteEvent(FcmTokenDeleteEvent event) { | ||
userService.deleteFcmTokens(event.getFcmTokens()); | ||
} | ||
|
||
} | ||
|
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/wakeUpTogetUp/togetUp/api/users/fcmToken/FcmTokenDeleteEvent.java
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.wakeUpTogetUp.togetUp.api.users.fcmToken; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class FcmTokenDeleteEvent { | ||
private final List<String> fcmTokens; | ||
} |
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
Oops, something went wrong.
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.
P5: 해당 메서드의 인수에서 ~event 클래스를 받지 않는데 특별히 이렇게 구현하신 이유가 있을까요?
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.
어떤 것이 궁금하신가요??
NotificationSendVo의 이름을 NotificationSendEvent로 하지 않은 이유가 궁금하신지
아니면 NotificationEventPublisher의 구현이 궁금하신지 알려주시면 좋을 것 같습니다!
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.
eventPublisher는 event를 인수로 받는다고 알고 있는데 따로 event를 만들지 않고 Vo를 사용하신 이유 (재사용인지는 모르겠습니다)가 궁금합니다.
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.
내부 구현에 들어가면 오브젝트를 인자로 받을 수 있습니다! 원래 이름이 NotificationSendVo이였는데 변경할 생각을 못했습니다. NotificationSendEvent으로 변경해도 좋을 것 같네요!
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.
네 내부에서는 Object를 받지만 해당 클래스를 vo로 사용할 것인지 event로 사용할것인지 명확하게 하기 위해 클래스 이름을 변경하는 것이 좋아보입니다.
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.
네 수정하겠습니다 :)