From 03de1c3a527dde03776dc63a020ec4506645c046 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Fri, 30 Jun 2023 18:17:13 +0100 Subject: [PATCH 1/3] fix(AdminSdkFcmSender): make sure ttl is vaild --- .../radarbase/fcm/downstream/AdminSdkFcmSender.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java b/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java index 27e3e89c..e5a224b9 100644 --- a/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java +++ b/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java @@ -55,6 +55,7 @@ @Slf4j @SuppressWarnings({"PMD.DataflowAnomalyAnalysis", "PMD.AvoidDuplicateLiterals"}) public class AdminSdkFcmSender implements FcmSender { + static final int DEFAULT_TIME_TO_LIVE = 2_419_200; // 28 days in seconds public AdminSdkFcmSender() throws IOException { // TODO also take config from application properties @@ -81,7 +82,7 @@ public void send(FcmDownstreamMessage downstreamMessage) throws FirebaseMessagin .setFcmOptions(FcmOptions.builder().build()) .setCondition(downstreamMessage.getCondition()); - int ttl = downstreamMessage.getTimeToLive() * 1000; // Convert to milliseconds + int ttl = getValidTtlMillis(downstreamMessage.getTimeToLive()); if (downstreamMessage instanceof FcmNotificationMessage) { FcmNotificationMessage notificationMessage = (FcmNotificationMessage) downstreamMessage; @@ -260,4 +261,11 @@ private String getString(Object obj) { public boolean doesProvideDeliveryReceipt() { return false; } + + public int getValidTtlMillis(int ttl) { + // Converts ttl from seconds to milliseconds and makes sure this is less than 28 days + int ttlSeconds = ttl >= 0 && ttl <= DEFAULT_TIME_TO_LIVE ? ttl : DEFAULT_TIME_TO_LIVE; + return ttlSeconds * 1000; + } + } From 58db407311504449ac1de862b36d17a416e2bba9 Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Fri, 30 Jun 2023 19:01:30 +0100 Subject: [PATCH 2/3] fix(adminsdkfcmsender): change max ttl to 21 days --- .../java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java b/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java index e5a224b9..5dfb8638 100644 --- a/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java +++ b/src/main/java/org/radarbase/fcm/downstream/AdminSdkFcmSender.java @@ -55,7 +55,7 @@ @Slf4j @SuppressWarnings({"PMD.DataflowAnomalyAnalysis", "PMD.AvoidDuplicateLiterals"}) public class AdminSdkFcmSender implements FcmSender { - static final int DEFAULT_TIME_TO_LIVE = 2_419_200; // 28 days in seconds + static final int DEFAULT_TIME_TO_LIVE = 1_814_000; // 21 days in seconds public AdminSdkFcmSender() throws IOException { // TODO also take config from application properties From fdd2cb44649f0107db37d50fda82f0ea47e4a43c Mon Sep 17 00:00:00 2001 From: mpgxvii Date: Fri, 30 Jun 2023 19:02:37 +0100 Subject: [PATCH 3/3] chore: bump version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 93bfa461..95b47531 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ apply plugin: 'io.spring.dependency-management' apply plugin: 'scala' group = 'org.radarbase' -version = '2.0.0' +version = '2.0.2' sourceCompatibility = 11 repositories {