From 54d2909e537350791a41062815ef512cc37e5f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:44:09 +0900 Subject: [PATCH 1/4] =?UTF-8?q?hotfix=20:=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=A6=AC=EB=A7=88=EC=9D=B8=EB=93=9C=20=ED=91=B8?= =?UTF-8?q?=EC=8B=9C=EC=95=8C=EB=A6=BC=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=EB=A1=9C=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/AlarmHistoryController.java | 3 ++ .../service/UpdateRemindAlarmUseCase.java | 30 +++++++++++-------- .../repository/MemberCustomRepository.java | 3 +- .../MemberCustomRepositoryImpl.java | 4 ++- .../domain/repository/MemberRepository.java | 2 ++ .../domain/service/MemberGetService.java | 4 +-- .../dto/request/PostUpdatePushAlarm.java | 14 +++++++++ .../presentation/RemindAlarmController.java | 29 ++++++++++++++++++ 8 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/moing/backend/domain/member/dto/request/PostUpdatePushAlarm.java create mode 100644 src/main/java/com/moing/backend/domain/member/presentation/RemindAlarmController.java diff --git a/src/main/java/com/moing/backend/domain/history/presentation/AlarmHistoryController.java b/src/main/java/com/moing/backend/domain/history/presentation/AlarmHistoryController.java index ba847a61..e5d183f3 100644 --- a/src/main/java/com/moing/backend/domain/history/presentation/AlarmHistoryController.java +++ b/src/main/java/com/moing/backend/domain/history/presentation/AlarmHistoryController.java @@ -23,6 +23,7 @@ public class AlarmHistoryController { private final GetAlarmHistoryUseCase getAlarmHistoryUseCase; private final ReadAlarmHistoryUseCase readAlarmHistoryUseCase; + /** * 알림 전체 조회 * [GET] api/history/alarm @@ -52,4 +53,6 @@ public ResponseEntity readAlarmHistory(@AuthenticationPrincipal public ResponseEntity> getUnreadAlarmCount(@AuthenticationPrincipal User user) { return ResponseEntity.ok(SuccessResponse.create(GET_UNREAD_ALARM_HISTORY.getMessage(), getAlarmHistoryUseCase.getUnreadAlarmCount(user.getSocialId()))); } + + } diff --git a/src/main/java/com/moing/backend/domain/member/application/service/UpdateRemindAlarmUseCase.java b/src/main/java/com/moing/backend/domain/member/application/service/UpdateRemindAlarmUseCase.java index 0f535603..d4203f0d 100644 --- a/src/main/java/com/moing/backend/domain/member/application/service/UpdateRemindAlarmUseCase.java +++ b/src/main/java/com/moing/backend/domain/member/application/service/UpdateRemindAlarmUseCase.java @@ -38,23 +38,29 @@ public class UpdateRemindAlarmUseCase { String REMIND_NAME = "미션 리마인드"; - public Boolean sendUpdateAppPushAlarm() { + public void sendUpdateAppPushAlarm(String title, String message) { - String title = "MOING 업데이트 소식"; - String message = "이제 누구나 미션을 만들 수 있어요. 지금 업데이트하고 다른 소식도 확인해보세요!"; +// String title = "MOING 업데이트 소식"; +// String message = "이제 누구나 미션을 만들 수 있어요. 지금 업데이트하고 다른 소식도 확인해보세요!"; - List allMemberOfPushAlarm = memberGetService.getAllMemberOfPushAlarm(); + long count = memberGetService.getAllMemberOfPushAlarm(0L, Long.MAX_VALUE).size(); - Optional> memberIdAndTokens = mapToMemberAndToken(allMemberOfPushAlarm); - Optional> pushMemberIdAndToken = isPushMemberIdAndToken(allMemberOfPushAlarm); + for (Long offset = 0L; offset < count; offset += 499) { - if (pushMemberIdAndToken.isPresent() && !pushMemberIdAndToken.get().isEmpty()) { - multiMessageSender.send(new MultiRequest(pushMemberIdAndToken.get(), title, message, "", REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue())); - } - if (memberIdAndTokens.isPresent() && !memberIdAndTokens.get().isEmpty()) { - saveMultiAlarmHistoryUseCase.saveAlarmHistories(AlarmHistoryMapper.getMemberIds(memberIdAndTokens.get()), "", title, message, REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue()); + Long limit = offset+499; + + List allMemberOfPushAlarm = memberGetService.getAllMemberOfPushAlarm(offset, limit); + + Optional> memberIdAndTokens = mapToMemberAndToken(allMemberOfPushAlarm); + Optional> pushMemberIdAndToken = isPushMemberIdAndToken(allMemberOfPushAlarm); + + if (pushMemberIdAndToken.isPresent() && !pushMemberIdAndToken.get().isEmpty()) { + multiMessageSender.send(new MultiRequest(pushMemberIdAndToken.get(), title, message, "", REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue())); + } + if (memberIdAndTokens.isPresent() && !memberIdAndTokens.get().isEmpty()) { + saveMultiAlarmHistoryUseCase.saveAlarmHistories(AlarmHistoryMapper.getMemberIds(memberIdAndTokens.get()), "", title, message, REMIND_NAME, AlarmType.REMIND, PagePath.MISSION_ALL_PTAH.getValue()); + } } - return true; } diff --git a/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepository.java b/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepository.java index 4133dba8..b6b2f76e 100644 --- a/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepository.java +++ b/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepository.java @@ -13,5 +13,6 @@ public interface MemberCustomRepository { Optional findNotDeletedByMemberId(Long id); Long getTodayNewMembers(); Long getYesterdayNewMembers(); - Optional> findAllMemberOnPushAlarm(); + + Optional> findAllMemberOnPushAlarm(Long offset, Long limit); } diff --git a/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepositoryImpl.java b/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepositoryImpl.java index f5a2a5bd..1fa3873a 100644 --- a/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/moing/backend/domain/member/domain/repository/MemberCustomRepositoryImpl.java @@ -88,7 +88,7 @@ public Long getYesterdayNewMembers() { } @Override - public Optional> findAllMemberOnPushAlarm() { + public Optional> findAllMemberOnPushAlarm(Long offset, Long limit) { return Optional.ofNullable( queryFactory.selectFrom(member) .where( @@ -96,6 +96,8 @@ public Optional> findAllMemberOnPushAlarm() { member.isRemindPush.eq(true), member.isSignOut.eq(false) ) + .offset(offset) + .limit(limit) .fetch() ); } diff --git a/src/main/java/com/moing/backend/domain/member/domain/repository/MemberRepository.java b/src/main/java/com/moing/backend/domain/member/domain/repository/MemberRepository.java index 8bc9886c..c797cf41 100644 --- a/src/main/java/com/moing/backend/domain/member/domain/repository/MemberRepository.java +++ b/src/main/java/com/moing/backend/domain/member/domain/repository/MemberRepository.java @@ -2,5 +2,7 @@ import com.moing.backend.domain.member.domain.entity.Member; import org.springframework.data.jpa.repository.JpaRepository; + public interface MemberRepository extends JpaRepository, MemberCustomRepository { + } diff --git a/src/main/java/com/moing/backend/domain/member/domain/service/MemberGetService.java b/src/main/java/com/moing/backend/domain/member/domain/service/MemberGetService.java index 85153003..36013dce 100644 --- a/src/main/java/com/moing/backend/domain/member/domain/service/MemberGetService.java +++ b/src/main/java/com/moing/backend/domain/member/domain/service/MemberGetService.java @@ -33,7 +33,7 @@ public Long getYesterdayNewMembers(){ } - public List getAllMemberOfPushAlarm() { - return memberRepository.findAllMemberOnPushAlarm().orElseThrow(NotFoundRemindAlarmException::new); + public List getAllMemberOfPushAlarm(Long offset, Long limit) { + return memberRepository.findAllMemberOnPushAlarm(offset,limit).orElseThrow(NotFoundRemindAlarmException::new); } } diff --git a/src/main/java/com/moing/backend/domain/member/dto/request/PostUpdatePushAlarm.java b/src/main/java/com/moing/backend/domain/member/dto/request/PostUpdatePushAlarm.java new file mode 100644 index 00000000..bc5d0fe6 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/member/dto/request/PostUpdatePushAlarm.java @@ -0,0 +1,14 @@ +package com.moing.backend.domain.member.dto.request; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class PostUpdatePushAlarm { + + private String title; + private String message; +} diff --git a/src/main/java/com/moing/backend/domain/member/presentation/RemindAlarmController.java b/src/main/java/com/moing/backend/domain/member/presentation/RemindAlarmController.java new file mode 100644 index 00000000..799d7437 --- /dev/null +++ b/src/main/java/com/moing/backend/domain/member/presentation/RemindAlarmController.java @@ -0,0 +1,29 @@ +package com.moing.backend.domain.member.presentation; + +import com.moing.backend.domain.member.application.service.UpdateRemindAlarmUseCase; +import com.moing.backend.domain.member.dto.request.PostUpdatePushAlarm; +import com.moing.backend.global.config.security.dto.User; +import com.moing.backend.global.response.SuccessResponse; +import lombok.AllArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/api/remind/alarm") +public class RemindAlarmController { + + private final UpdateRemindAlarmUseCase updateRemindAlarmUseCase; + + + @PostMapping("/update") + public ResponseEntity> postUpdateRemindAlarm(@AuthenticationPrincipal User user , @RequestBody PostUpdatePushAlarm postUpdatePushAlarm) { + updateRemindAlarmUseCase.sendUpdateAppPushAlarm(postUpdatePushAlarm.getTitle(), postUpdatePushAlarm.getMessage()); + return ResponseEntity.ok(SuccessResponse.create("remindAlarm Done")); + } + +} From c39f82e092b8769d09cee77f5225c44212337fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:12:02 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20FCM=20SDK=20=EC=97=85=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4ca667bb..a3f3499a 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ dependencies { implementation 'com.google.code.gson:gson:2.8.7' // Push Alarm - implementation 'com.google.firebase:firebase-admin:8.2.0' + implementation 'com.google.firebase:firebase-admin:9.2.0' implementation 'com.google.firebase:firebase-messaging:23.0.0' // RestDocs From 18f5f150d3dc16b9da39d43ac2619adbc66012e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:34:19 +0900 Subject: [PATCH 3/4] =?UTF-8?q?hotfix=20:=20deprecated=20=EB=90=9C=20sendM?= =?UTF-8?q?ulticast=20=EB=8C=80=EC=8B=A0=20sendEachForMulticast=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/global/config/fcm/service/MultiMessageSender.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moing/backend/global/config/fcm/service/MultiMessageSender.java b/src/main/java/com/moing/backend/global/config/fcm/service/MultiMessageSender.java index ec54e038..f5bdcfba 100644 --- a/src/main/java/com/moing/backend/global/config/fcm/service/MultiMessageSender.java +++ b/src/main/java/com/moing/backend/global/config/fcm/service/MultiMessageSender.java @@ -70,7 +70,8 @@ public void send(MultiRequest request) { .build(); try { - BatchResponse response = firebaseMessaging.sendMulticast(message); +// BatchResponse response = firebaseMessaging.sendMulticast(message); + BatchResponse response = firebaseMessaging.sendEachForMulticast(message); List failedTokens = new ArrayList<>(); From 46943aafd84f3fa1c8015643b39494e1e95cb8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=20=EC=8A=B9=20=EC=97=B0?= <53565255+seungyeonnnnnni@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:34:41 +0900 Subject: [PATCH 4/4] =?UTF-8?q?hotfix=20:=20gitaction=20=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=EB=9F=AC=EB=A6=AC=20=EB=B2=84=EC=A0=84=20=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD-prod.yml | 10 +++++----- .github/workflows/CI-dev.yml | 12 ++++++------ .github/workflows/CI-prod.yml | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/CD-prod.yml b/.github/workflows/CD-prod.yml index 4a541082..c14325ab 100644 --- a/.github/workflows/CD-prod.yml +++ b/.github/workflows/CD-prod.yml @@ -18,7 +18,7 @@ jobs: steps: # 소스 코드 체크아웃 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # JDK 11 설정 - name: Set up JDK 11 @@ -29,7 +29,7 @@ jobs: # Gradle 패키지 캐시 - name: Cache Gradle packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -49,17 +49,17 @@ jobs: echo "${{env.APPLE_KEY}}" > ./apple-key.p8 # 설정 파일을 작업공간에 저장 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: application.yml path: ./src/main/resources/application.yml - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: firebase-key.json path: ./src/main/resources/firebase-key.json - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: apple-key.p8 path: ./src/main/resources/apple-key.p8 diff --git a/.github/workflows/CI-dev.yml b/.github/workflows/CI-dev.yml index caeb3688..608249cb 100644 --- a/.github/workflows/CI-dev.yml +++ b/.github/workflows/CI-dev.yml @@ -19,18 +19,18 @@ jobs: steps: # 소스 코드 체크아웃 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # JDK 11 설정 - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: '11' distribution: 'adopt' # Gradle 패키지 캐시 - name: Cache Gradle packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -50,17 +50,17 @@ jobs: echo "${{env.APPLE_KEY}}" > ./apple-key.p8 # 설정 파일을 작업공간에 저장 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: application.yml path: ./src/main/resources/application.yml - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: firebase-key.json path: ./src/main/resources/firebase-key.json - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: apple-key.p8 path: ./src/main/resources/apple-key.p8 diff --git a/.github/workflows/CI-prod.yml b/.github/workflows/CI-prod.yml index ee7e333c..57bd93bd 100644 --- a/.github/workflows/CI-prod.yml +++ b/.github/workflows/CI-prod.yml @@ -19,18 +19,18 @@ jobs: steps: # 소스 코드 체크아웃 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # JDK 11 설정 - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: '11' distribution: 'adopt' # Gradle 패키지 캐시 - name: Cache Gradle packages - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -50,17 +50,17 @@ jobs: echo "${{env.APPLE_KEY}}" > ./apple-key.p8 # 설정 파일을 작업공간에 저장 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: application.yml path: ./src/main/resources/application.yml - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: firebase-key.json path: ./src/main/resources/firebase-key.json - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: apple-key.p8 path: ./src/main/resources/apple-key.p8