Skip to content

Commit

Permalink
Align push notification types and delivery priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-signal committed Dec 6, 2023
1 parent db17693 commit 34a9438
Showing 1 changed file with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,28 @@ public CompletableFuture<SendPushNotificationResult> sendNotification(final Push
.build();
};

final PushType pushType;
final PushType pushType = switch (notification.notificationType()) {
case NOTIFICATION -> {
if (isVoip) {
yield PushType.VOIP;
} else {
yield notification.urgent() ? PushType.ALERT : PushType.BACKGROUND;
}
}
case ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY -> PushType.ALERT;
case CHALLENGE, RATE_LIMIT_CHALLENGE -> PushType.BACKGROUND;
};

final DeliveryPriority deliveryPriority;

if (isVoip) {
pushType = PushType.VOIP;
if (pushType == PushType.BACKGROUND) {
deliveryPriority = DeliveryPriority.CONSERVE_POWER;
} else {
pushType = notification.urgent() ? PushType.ALERT : PushType.BACKGROUND;
deliveryPriority = (notification.urgent() || isVoip)
? DeliveryPriority.IMMEDIATE
: DeliveryPriority.CONSERVE_POWER;
}

final DeliveryPriority deliveryPriority = switch (notification.notificationType()) {
case NOTIFICATION ->
(notification.urgent() || isVoip) ? DeliveryPriority.IMMEDIATE : DeliveryPriority.CONSERVE_POWER;
case ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY -> DeliveryPriority.IMMEDIATE;
case CHALLENGE, RATE_LIMIT_CHALLENGE -> DeliveryPriority.CONSERVE_POWER;
};

final String collapseId =
(notification.notificationType() == PushNotification.NotificationType.NOTIFICATION && notification.urgent() && !isVoip)
? "incoming-message" : null;
Expand Down

0 comments on commit 34a9438

Please sign in to comment.