Skip to content

Commit

Permalink
v1.1.1
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
char-yb authored Sep 13, 2024
2 parents 8ed851b + dd080ae commit a4f5307
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ public void checkAndSendBoostNotification(MissionRecord missionRecord) {
Optional<FcmNotificationConstants> notificationType =
determineNotificationType(totalBoostCount);

long boostCount = determineBoostCount(totalBoostCount);

notificationType.ifPresent(
type -> {
if (!notificationAlreadySent(missionRecord, type)) {
sendBoostNotification(missionRecord, type);
sendBoostNotification(missionRecord, type, boostCount);
}
});
}
Expand Down Expand Up @@ -178,8 +180,24 @@ private Optional<FcmNotificationConstants> 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())
Expand All @@ -188,7 +206,7 @@ private void sendBoostNotification(

String deepLink =
FcmNotification.generateDeepLink(
FcmNotificationType.BOOSTER, missionRecord.getId());
FcmNotificationType.BOOSTER, missionRecord.getId(), boostCount);

FcmMessage fcmMessage =
FcmMessage.of(
Expand Down Expand Up @@ -242,7 +260,7 @@ private List<FcmNotification> buildNotificationList(
public void sendAndNotifications(String title, String message, List<String> tokens) {
List<List<String>> batches = createBatches(tokens, 10);

String deepLink = FcmNotification.generateDeepLink(FcmNotificationType.MISSION, null);
String deepLink = FcmNotification.generateDeepLink(FcmNotificationType.MISSION, null, null);

for (List<String> batch : batches) {
sqsMessageService.sendBatchMessages(batch, title, message, deepLink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a4f5307

Please sign in to comment.