Remove low priority attempt login notification workaround for old iOS clients
This commit is contained in:
parent
a83378a44e
commit
d4ef2adf0a
|
@ -102,11 +102,6 @@ public class APNSender implements Managed, PushNotificationSender {
|
||||||
.addCustomProperty("attemptLoginContext", notification.data())
|
.addCustomProperty("attemptLoginContext", notification.data())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
case ATTEMPT_LOGIN_NOTIFICATION_LOW_PRIORITY -> new SimpleApnsPayloadBuilder()
|
|
||||||
.setContentAvailable(true)
|
|
||||||
.addCustomProperty("attemptLoginContext", notification.data())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
case CHALLENGE -> new SimpleApnsPayloadBuilder()
|
case CHALLENGE -> new SimpleApnsPayloadBuilder()
|
||||||
.setContentAvailable(true)
|
.setContentAvailable(true)
|
||||||
.addCustomProperty("challenge", notification.data())
|
.addCustomProperty("challenge", notification.data())
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class FcmSender implements PushNotificationSender {
|
||||||
|
|
||||||
final String key = switch (pushNotification.notificationType()) {
|
final String key = switch (pushNotification.notificationType()) {
|
||||||
case NOTIFICATION -> "newMessageAlert";
|
case NOTIFICATION -> "newMessageAlert";
|
||||||
case ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, ATTEMPT_LOGIN_NOTIFICATION_LOW_PRIORITY -> "attemptLoginContext";
|
case ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY -> "attemptLoginContext";
|
||||||
case CHALLENGE -> "challenge";
|
case CHALLENGE -> "challenge";
|
||||||
case RATE_LIMIT_CHALLENGE -> "rateLimitChallenge";
|
case RATE_LIMIT_CHALLENGE -> "rateLimitChallenge";
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,6 @@ public record PushNotification(String deviceToken,
|
||||||
public enum NotificationType {
|
public enum NotificationType {
|
||||||
NOTIFICATION,
|
NOTIFICATION,
|
||||||
ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY,
|
ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY,
|
||||||
@Deprecated ATTEMPT_LOGIN_NOTIFICATION_LOW_PRIORITY, // Temporary support for iOS clients; can be removed after 2023-06-12
|
|
||||||
CHALLENGE,
|
CHALLENGE,
|
||||||
RATE_LIMIT_CHALLENGE
|
RATE_LIMIT_CHALLENGE
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,13 +76,6 @@ public class PushNotificationManager {
|
||||||
sendNotification(new PushNotification(tokenAndType.first(), tokenAndType.second(),
|
sendNotification(new PushNotification(tokenAndType.first(), tokenAndType.second(),
|
||||||
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY,
|
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY,
|
||||||
context, destination, device, true));
|
context, destination, device, true));
|
||||||
|
|
||||||
// This is a workaround for older iOS clients who need a low priority push to trigger the logout notification
|
|
||||||
if (tokenAndType.second() == PushNotification.TokenType.APN) {
|
|
||||||
sendNotification(new PushNotification(tokenAndType.first(), tokenAndType.second(),
|
|
||||||
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_LOW_PRIORITY,
|
|
||||||
context, destination, device, false));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessagesRetrieved(final Account account, final Device device, final String userAgent) {
|
public void handleMessagesRetrieved(final Account account, final Device device, final String userAgent) {
|
||||||
|
|
|
@ -115,8 +115,6 @@ class PushNotificationManagerTest {
|
||||||
when(device.getApnId()).thenReturn(deviceToken);
|
when(device.getApnId()).thenReturn(deviceToken);
|
||||||
when(apnSender.sendNotification(any()))
|
when(apnSender.sendNotification(any()))
|
||||||
.thenReturn(CompletableFuture.completedFuture(new SendPushNotificationResult(true, null, false)));
|
.thenReturn(CompletableFuture.completedFuture(new SendPushNotificationResult(true, null, false)));
|
||||||
when(apnPushNotificationScheduler.scheduleBackgroundNotification(account, device))
|
|
||||||
.thenReturn(CompletableFuture.completedFuture(null));
|
|
||||||
} else {
|
} else {
|
||||||
when(device.getGcmId()).thenReturn(deviceToken);
|
when(device.getGcmId()).thenReturn(deviceToken);
|
||||||
when(fcmSender.sendNotification(any()))
|
when(fcmSender.sendNotification(any()))
|
||||||
|
@ -129,7 +127,6 @@ class PushNotificationManagerTest {
|
||||||
if (isApn){
|
if (isApn){
|
||||||
verify(apnSender).sendNotification(new PushNotification(deviceToken, PushNotification.TokenType.APN,
|
verify(apnSender).sendNotification(new PushNotification(deviceToken, PushNotification.TokenType.APN,
|
||||||
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, "someContext", account, device, true));
|
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, "someContext", account, device, true));
|
||||||
verify(apnPushNotificationScheduler).scheduleBackgroundNotification(account, device);
|
|
||||||
} else {
|
} else {
|
||||||
verify(fcmSender, times(1)).sendNotification(new PushNotification(deviceToken, PushNotification.TokenType.FCM,
|
verify(fcmSender, times(1)).sendNotification(new PushNotification(deviceToken, PushNotification.TokenType.FCM,
|
||||||
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, "someContext", account, device, true));
|
PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, "someContext", account, device, true));
|
||||||
|
|
Loading…
Reference in New Issue