From dd080ae57b4c1689437c36e44bd4e70839f8416e Mon Sep 17 00:00:00 2001 From: ybchar Date: Fri, 13 Sep 2024 21:46:14 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20=EC=95=8C=EB=A6=BC=20deepLink=20prefi?= =?UTF-8?q?x=20boostCount=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/FcmNotificationService.java | 26 ++++++++++++++++--- .../domain/fcm/domain/FcmNotification.java | 5 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/depromeet/stonebed/domain/fcm/application/FcmNotificationService.java b/src/main/java/com/depromeet/stonebed/domain/fcm/application/FcmNotificationService.java index ee7489c..99dbc0c 100644 --- a/src/main/java/com/depromeet/stonebed/domain/fcm/application/FcmNotificationService.java +++ b/src/main/java/com/depromeet/stonebed/domain/fcm/application/FcmNotificationService.java @@ -147,10 +147,12 @@ public void checkAndSendBoostNotification(MissionRecord missionRecord) { Optional notificationType = determineNotificationType(totalBoostCount); + long boostCount = determineBoostCount(totalBoostCount); + notificationType.ifPresent( type -> { if (!notificationAlreadySent(missionRecord, type)) { - sendBoostNotification(missionRecord, type); + sendBoostNotification(missionRecord, type, boostCount); } }); } @@ -178,8 +180,24 @@ private Optional determineNotificationType(Long totalB return Optional.empty(); } + private long determineBoostCount(Long totalBoostCount) { + if (totalBoostCount >= SUPER_POPULAR_THRESHOLD) { + return SUPER_POPULAR_THRESHOLD; + } + if (totalBoostCount >= POPULAR_THRESHOLD) { + return POPULAR_THRESHOLD; + } + if (totalBoostCount >= FIRST_BOOST_THRESHOLD) { + return FIRST_BOOST_THRESHOLD; + } + + return 0; + } + private void sendBoostNotification( - MissionRecord missionRecord, FcmNotificationConstants notificationConstants) { + MissionRecord missionRecord, + FcmNotificationConstants notificationConstants, + long boostCount) { String token = fcmRepository .findByMember(missionRecord.getMember()) @@ -188,7 +206,7 @@ private void sendBoostNotification( String deepLink = FcmNotification.generateDeepLink( - FcmNotificationType.BOOSTER, missionRecord.getId()); + FcmNotificationType.BOOSTER, missionRecord.getId(), boostCount); FcmMessage fcmMessage = FcmMessage.of( @@ -242,7 +260,7 @@ private List buildNotificationList( public void sendAndNotifications(String title, String message, List tokens) { List> batches = createBatches(tokens, 10); - String deepLink = FcmNotification.generateDeepLink(FcmNotificationType.MISSION, null); + String deepLink = FcmNotification.generateDeepLink(FcmNotificationType.MISSION, null, null); for (List batch : batches) { sqsMessageService.sendBatchMessages(batch, title, message, deepLink); diff --git a/src/main/java/com/depromeet/stonebed/domain/fcm/domain/FcmNotification.java b/src/main/java/com/depromeet/stonebed/domain/fcm/domain/FcmNotification.java index 683e047..4060646 100644 --- a/src/main/java/com/depromeet/stonebed/domain/fcm/domain/FcmNotification.java +++ b/src/main/java/com/depromeet/stonebed/domain/fcm/domain/FcmNotification.java @@ -70,11 +70,12 @@ public void markAsRead() { this.isRead = true; } - public static String generateDeepLink(FcmNotificationType type, Long targetId) { + public static String generateDeepLink( + FcmNotificationType type, Long targetId, Long boostCount) { if (type == FcmNotificationType.MISSION) { return DEEP_LINK_PREFIX + "mission"; } else if (type == FcmNotificationType.BOOSTER) { - return DEEP_LINK_PREFIX + "boost?id=" + targetId; + return DEEP_LINK_PREFIX + "boost?id=" + targetId + "&type=" + boostCount; } return null; }