Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time to live hotfix #435

Closed
wants to merge 3 commits into from
Closed

Time to live hotfix #435

wants to merge 3 commits into from

Conversation

mpgxvii
Copy link
Member

@mpgxvii mpgxvii commented Jun 30, 2023

@@ -190,4 +192,8 @@ public MessageType getMessageType(T message) {
return MessageType.UNKNOWN;
}
}

private static int getValidTimeToLive(int ttl) {
return ValueRange.of(0, DEFAULT_TIME_TO_LIVE).isValidIntValue(ttl) ? ttl : DEFAULT_TIME_TO_LIVE;
Copy link
Member

@yatharthranjan yatharthranjan Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simply do if comparison

return ttl >= 0 && ttl <= DEFAULT_TIME_TO_LIVE ? ttl : DEFAULT_TIME_TO_LIVE;

This will be much faster than comparing with a range.

@@ -61,7 +61,7 @@ private static FcmDataMessage createMessageFromDataMessage(DataMessage dataMessa
.mutableContent(dataMessage.isMutableContent())
.deliveryReceiptRequested(IS_DELIVERY_RECEIPT_REQUESTED)
.messageId(String.valueOf(dataMessage.getFcmMessageId()))
.timeToLive(Objects.requireNonNullElse(dataMessage.getTtlSeconds(), 2_419_200))
.timeToLive(getValidTimeToLive(dataMessage.getTtlSeconds()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this check to the FcmSender in the fcm package as this a FCM level restriction rather than of the appserver. This would ensure any future uses elsewhere of the send fcm function works as expected too.

@mpgxvii mpgxvii changed the base branch from master to v2.0.1 June 30, 2023 17:18
Copy link
Member

@yatharthranjan yatharthranjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mpgxvii
Copy link
Member Author

mpgxvii commented Jun 30, 2023

@mpgxvii
Copy link
Member Author

mpgxvii commented Jul 12, 2023

Closing as this hotfix has been released. Also been added to: #434

@mpgxvii mpgxvii closed this Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants