From 2aebe0883b173f2d9c3b4a9b6974acf5dddc2a94 Mon Sep 17 00:00:00 2001 From: j-yong99 Date: Wed, 22 May 2024 14:47:07 +0900 Subject: [PATCH] =?UTF-8?q?:bug:=20=ED=9A=8C=EC=9B=90=ED=83=88=ED=87=B4?= =?UTF-8?q?=EC=8B=9C=20S3=EC=97=90=20=EC=82=AD=EC=A0=9C=20=EC=95=88?= =?UTF-8?q?=EB=90=98=EB=8D=98=20=EB=B2=84=EA=B7=B8=20=ED=95=B4=EA=B2=B0,?= =?UTF-8?q?=20=EB=A7=A4=EC=9D=BC=202=EC=8B=9C=EC=97=90=EB=A7=8C=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=EB=B3=B4=EB=82=B4=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD,=201/2=ED=99=95=EB=A5=A0=EB=A1=9C=20?= =?UTF-8?q?=EC=97=AC=ED=96=89=EC=9D=B4=20=EC=95=84=EB=8B=88=EC=96=B4?= =?UTF-8?q?=EB=8F=84=20=EC=95=8C=EB=A6=BC=20=EB=B3=B4=EB=83=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/moment/core/service/UserService.java | 2 +- .../config/SchedulerConfiguration.java | 4 ++-- .../moment/scheduler/service/NotiService.java | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/moment/moment-server/core/src/main/java/com/moment/core/service/UserService.java b/backend/moment/moment-server/core/src/main/java/com/moment/core/service/UserService.java index 00208d0a6b..ae80dc3344 100644 --- a/backend/moment/moment-server/core/src/main/java/com/moment/core/service/UserService.java +++ b/backend/moment/moment-server/core/src/main/java/com/moment/core/service/UserService.java @@ -95,7 +95,7 @@ public void updateUserSetting(UserRequestDTO.updateUser request, Long userId) { public void deleteUser(Long userId) { User user = userRepository.findById(userId).orElseThrow(() -> new IllegalArgumentException("존재하지 않는 유저입니다.")); // S3 먼저 전부 삭제 -// s3Service.deleteFile("", String.valueOf(userId)); + s3Service.deleteFile("", String.valueOf(userId)); // 유저의 영수증 전부 삭제 receiptRepository.deleteAllByUser(user); // 유저의 imageFile 전부 삭제 diff --git a/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/config/SchedulerConfiguration.java b/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/config/SchedulerConfiguration.java index 26f6040277..4a039302de 100644 --- a/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/config/SchedulerConfiguration.java +++ b/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/config/SchedulerConfiguration.java @@ -18,8 +18,8 @@ public class SchedulerConfiguration { private final UserRepository userRepository; // 매일 오후 1시에 알림 발송 -// @Scheduled(cron = "0 0 13 * * *") - @Scheduled(cron = "22 06 * * * *") + @Scheduled(cron = "0 0 14 * * *") +// @Scheduled(cron = "22 06 * * * *") public void run() { log.info("Noti Scheduler is running"); try { diff --git a/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/service/NotiService.java b/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/service/NotiService.java index a673e3d770..6c15eb5de6 100644 --- a/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/service/NotiService.java +++ b/backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/service/NotiService.java @@ -71,7 +71,22 @@ public void sendQuestionNoti(User user, String question) { } if (!isTraveling){ log.info("User {} is not traveling today", user.getId()); - return; + int rand = (int) (Math.random() * 10); + if (rand % 2 == 0){ + log.info("Sending random notification to user {}", user.getId()); + try { + ResponseEntity ret = notiClient.pushMessage( + FcmSendDto.builder() + .token(user.getFirebaseToken()) + .title("moment") + .body("문득 갑자기 떠나보는건 어때요?") + .build() + ); + log.info("Notification sent to user {} with response {}", user.getId(), ret); + } catch (Exception e){ + log.error("Failed to send notification to user {}", user.getId()); + } + } } try { ResponseEntity ret = notiClient.pushMessage(