From 83a79921f576e536e7f379857ff62a5896a45c77 Mon Sep 17 00:00:00 2001 From: Seonheui Jeon <88873302+funnysunny08@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:45:04 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[Fix]=20=EB=B0=B0=ED=8F=AC=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20=ED=95=B4=EA=B2=B0=ED=95=9C=EB=8B=A4.=20(#?= =?UTF-8?q?194)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Refactor] 알림생성로직 관련 중복 코드 개선 * [Feat] fcm 관련 로직 구현 (#187) * [Feat] fcm service 구현하기 * #159 [Feat] createMessage queue * [Feat] 좋아요, 댓글 생성시 알림 발송 * [Feat] 메시지 큐 실험 성공, fcm만 되는지 확인필요 * [Feat] 푸시sender transactional 제거 * [Feat] fcm토큰 준비 * [Feat] rabbitMQ server ec2연결 및 token response 요구사항 반영수정 * [Feat] updateFcmtoken 구현 및 notification success notFound -> no content수정 * [Merge] merge confict 해결 * [Fix] 닉네임 수정 로직이랑 줄을 헷갈려서 버그 수정 * [FIX] merge conflict * [FIX] stash 결과 적용 * [Feat] 동의여부 기능 추가 및 fcm 메시지 전송 변경 * [Feat] 댓글, 좋아요 알림로직에 동의 여부 수정 및 예외처리 * [Fix] notificationresponse Id 수정 * [Fix] logic 수정 * Update cd.yml * Update gradle.yml * Revert "[Feat] fcm 관련 로직 구현 (#187)" This reverts commit 5672dbdd2ab278e3dab128e916f24256ff1295e4. * Update cd.yml * Update gradle.yml * [Fix] 배포 오류를 해결한다. (#193) * [Feat] fcm service 구현하기 * #159 [Feat] createMessage queue * [Feat] 좋아요, 댓글 생성시 알림 발송 * [Feat] 메시지 큐 실험 성공, fcm만 되는지 확인필요 * [Feat] 푸시sender transactional 제거 * [Feat] fcm토큰 준비 * [Feat] rabbitMQ server ec2연결 및 token response 요구사항 반영수정 * [Feat] updateFcmtoken 구현 및 notification success notFound -> no content수정 * [Merge] merge confict 해결 * [Fix] 닉네임 수정 로직이랑 줄을 헷갈려서 버그 수정 * [FIX] merge conflict * [FIX] stash 결과 적용 * [Feat] 동의여부 기능 추가 및 fcm 메시지 전송 변경 * [Feat] 댓글, 좋아요 알림로직에 동의 여부 수정 및 예외처리 * [Fix] notificationresponse Id 수정 * [Fix] logic 수정 --------- Co-authored-by: soohyun Co-authored-by: soohyun <49307946+sss4920@users.noreply.github.com> * Update cd.yml * Update gradle.yml --------- Co-authored-by: soohyun Co-authored-by: soohyun <49307946+sss4920@users.noreply.github.com> From 9105d97ae3e0fec07054b244d4d1f727cff2d957 Mon Sep 17 00:00:00 2001 From: Seonheui Jeon <88873302+funnysunny08@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:52:24 +0900 Subject: [PATCH 2/5] Update appspec.yml (#195) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Refactor] 알림생성로직 관련 중복 코드 개선 * [Feat] fcm 관련 로직 구현 (#187) * [Feat] fcm service 구현하기 * #159 [Feat] createMessage queue * [Feat] 좋아요, 댓글 생성시 알림 발송 * [Feat] 메시지 큐 실험 성공, fcm만 되는지 확인필요 * [Feat] 푸시sender transactional 제거 * [Feat] fcm토큰 준비 * [Feat] rabbitMQ server ec2연결 및 token response 요구사항 반영수정 * [Feat] updateFcmtoken 구현 및 notification success notFound -> no content수정 * [Merge] merge confict 해결 * [Fix] 닉네임 수정 로직이랑 줄을 헷갈려서 버그 수정 * [FIX] merge conflict * [FIX] stash 결과 적용 * [Feat] 동의여부 기능 추가 및 fcm 메시지 전송 변경 * [Feat] 댓글, 좋아요 알림로직에 동의 여부 수정 및 예외처리 * [Fix] notificationresponse Id 수정 * [Fix] logic 수정 * Update cd.yml * Update gradle.yml * Revert "[Feat] fcm 관련 로직 구현 (#187)" This reverts commit 5672dbdd2ab278e3dab128e916f24256ff1295e4. * Update cd.yml * Update gradle.yml * [Fix] 배포 오류를 해결한다. (#193) * [Feat] fcm service 구현하기 * #159 [Feat] createMessage queue * [Feat] 좋아요, 댓글 생성시 알림 발송 * [Feat] 메시지 큐 실험 성공, fcm만 되는지 확인필요 * [Feat] 푸시sender transactional 제거 * [Feat] fcm토큰 준비 * [Feat] rabbitMQ server ec2연결 및 token response 요구사항 반영수정 * [Feat] updateFcmtoken 구현 및 notification success notFound -> no content수정 * [Merge] merge confict 해결 * [Fix] 닉네임 수정 로직이랑 줄을 헷갈려서 버그 수정 * [FIX] merge conflict * [FIX] stash 결과 적용 * [Feat] 동의여부 기능 추가 및 fcm 메시지 전송 변경 * [Feat] 댓글, 좋아요 알림로직에 동의 여부 수정 및 예외처리 * [Fix] notificationresponse Id 수정 * [Fix] logic 수정 --------- Co-authored-by: soohyun Co-authored-by: soohyun <49307946+sss4920@users.noreply.github.com> * Update cd.yml * Update gradle.yml * Update appspec.yml --------- Co-authored-by: soohyun Co-authored-by: soohyun <49307946+sss4920@users.noreply.github.com> --- appspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appspec.yml b/appspec.yml index 44c46f6..2b9ffff 100644 --- a/appspec.yml +++ b/appspec.yml @@ -15,5 +15,5 @@ permissions: hooks: AfterInstall: - location: deploy.sh - timeout: 60 + timeout: 300 runas: ubuntu From d5d460eb59fa0b7d3f82840ec6a153b38e1ab40c Mon Sep 17 00:00:00 2001 From: Seonheui Jeon <88873302+funnysunny08@users.noreply.github.com> Date: Sat, 18 Nov 2023 00:43:58 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20getFCMToken=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20=EC=98=A4=EB=B2=84=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=93=9C=ED=95=9C=EB=8B=A4.=20(#197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Refactor] 알림생성로직 관련 중복 코드 개선 * [Feat] fcm 관련 로직 구현 (#187) * [Feat] fcm service 구현하기 * #159 [Feat] createMessage queue * [Feat] 좋아요, 댓글 생성시 알림 발송 * [Feat] 메시지 큐 실험 성공, fcm만 되는지 확인필요 * [Feat] 푸시sender transactional 제거 * [Feat] fcm토큰 준비 * [Feat] rabbitMQ server ec2연결 및 token response 요구사항 반영수정 * [Feat] updateFcmtoken 구현 및 notification success notFound -> no content수정 * [Merge] merge confict 해결 * [Fix] 닉네임 수정 로직이랑 줄을 헷갈려서 버그 수정 * [FIX] merge conflict * [FIX] stash 결과 적용 * [Feat] 동의여부 기능 추가 및 fcm 메시지 전송 변경 * [Feat] 댓글, 좋아요 알림로직에 동의 여부 수정 및 예외처리 * [Fix] notificationresponse Id 수정 * [Fix] logic 수정 * Update cd.yml * Update gradle.yml * Revert "[Feat] fcm 관련 로직 구현 (#187)" This reverts commit 5672dbdd2ab278e3dab128e916f24256ff1295e4. * Update cd.yml * Update gradle.yml * [Fix] 배포 오류를 해결한다. (#193) * [Feat] fcm service 구현하기 * #159 [Feat] createMessage queue * [Feat] 좋아요, 댓글 생성시 알림 발송 * [Feat] 메시지 큐 실험 성공, fcm만 되는지 확인필요 * [Feat] 푸시sender transactional 제거 * [Feat] fcm토큰 준비 * [Feat] rabbitMQ server ec2연결 및 token response 요구사항 반영수정 * [Feat] updateFcmtoken 구현 및 notification success notFound -> no content수정 * [Merge] merge confict 해결 * [Fix] 닉네임 수정 로직이랑 줄을 헷갈려서 버그 수정 * [FIX] merge conflict * [FIX] stash 결과 적용 * [Feat] 동의여부 기능 추가 및 fcm 메시지 전송 변경 * [Feat] 댓글, 좋아요 알림로직에 동의 여부 수정 및 예외처리 * [Fix] notificationresponse Id 수정 * [Fix] logic 수정 --------- Co-authored-by: soohyun Co-authored-by: soohyun <49307946+sss4920@users.noreply.github.com> * Update cd.yml * Update gradle.yml * Update appspec.yml * feat: getFCMToken 메서드를 오버라이드한다. (#196) --------- Co-authored-by: soohyun Co-authored-by: soohyun <49307946+sss4920@users.noreply.github.com> --- .../org/winey/server/domain/user/User.java | 29 +++++++++++++++---- .../winey/server/service/CommentService.java | 14 ++++----- .../winey/server/service/FeedLikeService.java | 3 +- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/winey/server/domain/user/User.java b/src/main/java/org/winey/server/domain/user/User.java index e3ad858..f20fdc0 100644 --- a/src/main/java/org/winey/server/domain/user/User.java +++ b/src/main/java/org/winey/server/domain/user/User.java @@ -1,9 +1,22 @@ package org.winey.server.domain.user; -import lombok.*; -import org.hibernate.annotations.ColumnDefault; +import java.util.List; +import java.util.Objects; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import org.hibernate.annotations.DynamicUpdate; import org.winey.server.domain.AuditingTimeEntity; import org.winey.server.domain.comment.Comment; import org.winey.server.domain.feed.Feed; @@ -12,9 +25,6 @@ import org.winey.server.domain.notification.Notification; import org.winey.server.domain.recommend.Recommend; -import javax.persistence.*; -import java.util.List; - @Entity @Getter @DynamicInsert @@ -88,4 +98,11 @@ public void updateNickname(String nickname) { public void updateFcmToken(String fcmToken) { this.fcmToken = fcmToken; } public void updateFcmIsAllowed(Boolean isAllowed){this.fcmIsAllowed = isAllowed;} + + public String getFcmToken() { + if (Objects.nonNull(this.fcmToken)) { + return this.fcmToken; + } + return null; + } } diff --git a/src/main/java/org/winey/server/service/CommentService.java b/src/main/java/org/winey/server/service/CommentService.java index 423d18b..c33c15a 100644 --- a/src/main/java/org/winey/server/service/CommentService.java +++ b/src/main/java/org/winey/server/service/CommentService.java @@ -1,24 +1,22 @@ package org.winey.server.service; +import java.util.Objects; import lombok.RequiredArgsConstructor; - import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.winey.server.common.message.MessageQueueSender; import org.winey.server.controller.response.comment.CommentResponseDto; import org.winey.server.controller.response.comment.DeleteCommentResponseDto; import org.winey.server.domain.comment.Comment; +import org.winey.server.domain.feed.Feed; import org.winey.server.domain.notification.NotiType; import org.winey.server.domain.notification.Notification; -import org.winey.server.exception.model.BadRequestException; -import org.winey.server.exception.model.CustomException; -import org.winey.server.exception.model.UnauthorizedException; -import org.winey.server.exception.model.UnprocessableEntityException; -import org.winey.server.infrastructure.CommentRepository; -import org.winey.server.domain.feed.Feed; import org.winey.server.domain.user.User; import org.winey.server.exception.Error; import org.winey.server.exception.model.NotFoundException; +import org.winey.server.exception.model.UnauthorizedException; +import org.winey.server.exception.model.UnprocessableEntityException; +import org.winey.server.infrastructure.CommentRepository; import org.winey.server.infrastructure.FeedRepository; import org.winey.server.infrastructure.NotiRepository; import org.winey.server.infrastructure.UserRepository; @@ -97,7 +95,7 @@ private void createNotificationInComment(Feed feed, Comment comment, User user) notification.updateResponseId(comment.getCommentId()); notification.updateRequestUserId(user.getUserId()); notiRepository.save(notification); - if (feed.getUser().getFcmIsAllowed() && !notification.getNotiReceiver().getFcmToken().isEmpty()) { //푸시알림에 동의했을 경우. + if (feed.getUser().getFcmIsAllowed() && Objects.nonNull(notification.getNotiReceiver().getFcmToken())) { //푸시알림에 동의했을 경우. messageQueueSender.pushSender( FcmRequestDto.of( notification.getNotiMessage(), diff --git a/src/main/java/org/winey/server/service/FeedLikeService.java b/src/main/java/org/winey/server/service/FeedLikeService.java index 8e80f12..1a3486e 100644 --- a/src/main/java/org/winey/server/service/FeedLikeService.java +++ b/src/main/java/org/winey/server/service/FeedLikeService.java @@ -1,5 +1,6 @@ package org.winey.server.service; +import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -75,7 +76,7 @@ private void createNotificationInLike(Feed feed, FeedLike like, User user) { notification.updateResponseId(like.getId()); notification.updateRequestUserId(user.getUserId()); notiRepository.save(notification); - if (feed.getUser().getFcmIsAllowed() && !notification.getNotiReceiver().getFcmToken().isEmpty()) { //푸시알림에 동의했을 경우. 피드 주인에게 알림 + if (feed.getUser().getFcmIsAllowed() && Objects.nonNull(notification.getNotiReceiver().getFcmToken())) { //푸시알림에 동의했을 경우. 피드 주인에게 알림 messageQueueSender.pushSender( FcmRequestDto.of( notification.getNotiMessage(), From ad410291b6a5401331bc8062e50350b4fa0879d8 Mon Sep 17 00:00:00 2001 From: soohyun Date: Sun, 3 Dec 2023 23:20:33 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Fix]=20fcm=20=ED=8E=98=EC=9D=B4=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/winey/server/service/FcmService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/winey/server/service/FcmService.java b/src/main/java/org/winey/server/service/FcmService.java index c9b0363..b537691 100644 --- a/src/main/java/org/winey/server/service/FcmService.java +++ b/src/main/java/org/winey/server/service/FcmService.java @@ -96,14 +96,14 @@ public void sendByToken(FcmRequestDto wineyNotification) { .putData("feedId", String.valueOf(wineyNotification.getFeedId())) .putData("notiType", String.valueOf(wineyNotification.getType())) .putData("token", wineyNotification.getToken()) - .setNotification(new Notification("위니 제국의 편지가 도착했어요.", wineyNotification.getMessage())) + .putData("title", "위니 제국의 편지가 도착했어요.") + .putData("message" ,wineyNotification.getMessage()) .setToken(wineyNotification.getToken()) .build(); // 요청에 대한 응답을 받을 response String response; try { - System.out.println("여까지는 왔다."); // 알림 발송 response = FirebaseMessaging.getInstance().send(message); System.out.println(response); From cb6ea5c1e10d78bd65d646193ea5f478ac6f9424 Mon Sep 17 00:00:00 2001 From: soohyun Date: Sun, 3 Dec 2023 23:25:38 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[Fix]=20fcmtoken=20response=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/winey/server/service/FcmService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/winey/server/service/FcmService.java b/src/main/java/org/winey/server/service/FcmService.java index b537691..fd94295 100644 --- a/src/main/java/org/winey/server/service/FcmService.java +++ b/src/main/java/org/winey/server/service/FcmService.java @@ -95,7 +95,6 @@ public void sendByToken(FcmRequestDto wineyNotification) { Message message = Message.builder() .putData("feedId", String.valueOf(wineyNotification.getFeedId())) .putData("notiType", String.valueOf(wineyNotification.getType())) - .putData("token", wineyNotification.getToken()) .putData("title", "위니 제국의 편지가 도착했어요.") .putData("message" ,wineyNotification.getMessage()) .setToken(wineyNotification.getToken())