From d4ef2adf0a0255f54753aa6b7f73eb9ad754c5e3 Mon Sep 17 00:00:00 2001 From: Katherine Date: Mon, 13 Nov 2023 09:06:55 -0800 Subject: [PATCH] Remove low priority attempt login notification workaround for old iOS clients --- .../org/whispersystems/textsecuregcm/push/APNSender.java | 5 ----- .../org/whispersystems/textsecuregcm/push/FcmSender.java | 2 +- .../textsecuregcm/push/PushNotification.java | 1 - .../textsecuregcm/push/PushNotificationManager.java | 7 ------- .../textsecuregcm/push/PushNotificationManagerTest.java | 3 --- 5 files changed, 1 insertion(+), 17 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java index 06e5dafe1..d67c2902e 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/APNSender.java @@ -102,11 +102,6 @@ public class APNSender implements Managed, PushNotificationSender { .addCustomProperty("attemptLoginContext", notification.data()) .build(); - case ATTEMPT_LOGIN_NOTIFICATION_LOW_PRIORITY -> new SimpleApnsPayloadBuilder() - .setContentAvailable(true) - .addCustomProperty("attemptLoginContext", notification.data()) - .build(); - case CHALLENGE -> new SimpleApnsPayloadBuilder() .setContentAvailable(true) .addCustomProperty("challenge", notification.data()) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/FcmSender.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/FcmSender.java index 15c39dae7..7c21411f8 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/FcmSender.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/FcmSender.java @@ -89,7 +89,7 @@ public class FcmSender implements PushNotificationSender { final String key = switch (pushNotification.notificationType()) { 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 RATE_LIMIT_CHALLENGE -> "rateLimitChallenge"; }; diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotification.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotification.java index 37cbda79e..d8ef420f4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotification.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotification.java @@ -20,7 +20,6 @@ public record PushNotification(String deviceToken, public enum NotificationType { NOTIFICATION, ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, - @Deprecated ATTEMPT_LOGIN_NOTIFICATION_LOW_PRIORITY, // Temporary support for iOS clients; can be removed after 2023-06-12 CHALLENGE, RATE_LIMIT_CHALLENGE } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java index 6e0543ee8..e1711141c 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/PushNotificationManager.java @@ -76,13 +76,6 @@ public class PushNotificationManager { sendNotification(new PushNotification(tokenAndType.first(), tokenAndType.second(), PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, 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) { diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationManagerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationManagerTest.java index e0e82d125..0e5a86127 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationManagerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationManagerTest.java @@ -115,8 +115,6 @@ class PushNotificationManagerTest { when(device.getApnId()).thenReturn(deviceToken); when(apnSender.sendNotification(any())) .thenReturn(CompletableFuture.completedFuture(new SendPushNotificationResult(true, null, false))); - when(apnPushNotificationScheduler.scheduleBackgroundNotification(account, device)) - .thenReturn(CompletableFuture.completedFuture(null)); } else { when(device.getGcmId()).thenReturn(deviceToken); when(fcmSender.sendNotification(any())) @@ -129,7 +127,6 @@ class PushNotificationManagerTest { if (isApn){ verify(apnSender).sendNotification(new PushNotification(deviceToken, PushNotification.TokenType.APN, PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, "someContext", account, device, true)); - verify(apnPushNotificationScheduler).scheduleBackgroundNotification(account, device); } else { verify(fcmSender, times(1)).sendNotification(new PushNotification(deviceToken, PushNotification.TokenType.FCM, PushNotification.NotificationType.ATTEMPT_LOGIN_NOTIFICATION_HIGH_PRIORITY, "someContext", account, device, true));