Update to Pushy 0.15.0

This commit is contained in:
Jon Chambers 2021-08-23 10:57:03 -04:00 committed by Jon Chambers
parent f2c6ca182d
commit a9339b7037
3 changed files with 12 additions and 9 deletions

View File

@ -49,7 +49,7 @@
<opentest4j.version>1.2.0</opentest4j.version>
<postgresql.version>9.4-1201-jdbc41</postgresql.version>
<protobuf.version>3.17.1</protobuf.version>
<pushy.version>0.14.2</pushy.version>
<pushy.version>0.15.0</pushy.version>
<resilience4j.version>1.5.0</resilience4j.version>
<semver4j.version>3.1.0</semver4j.version>
<slf4j.version>1.7.30</slf4j.version>

View File

@ -88,12 +88,15 @@ public class RetryingApnsClient {
if (response != null) {
if (response.isAccepted()) {
future.set(new ApnResult(ApnResult.Status.SUCCESS, null));
} else if ("Unregistered".equals(response.getRejectionReason()) ||
"BadDeviceToken".equals(response.getRejectionReason())) {
future.set(new ApnResult(ApnResult.Status.NO_SUCH_USER, response.getRejectionReason()));
} else {
logger.warn("Got APN failure: " + response.getRejectionReason());
future.set(new ApnResult(ApnResult.Status.GENERIC_FAILURE, response.getRejectionReason()));
final String rejectionReason = response.getRejectionReason().orElse(null);
if ("Unregistered".equals(rejectionReason) || "BadDeviceToken".equals(rejectionReason)) {
future.set(new ApnResult(ApnResult.Status.NO_SUCH_USER, rejectionReason));
} else {
logger.warn("Got APN failure: {}", rejectionReason);
future.set(new ApnResult(ApnResult.Status.GENERIC_FAILURE, rejectionReason));
}
}
} else {
logger.warn("Execution exception", cause);

View File

@ -128,7 +128,7 @@ public class APNSenderTest {
PushNotificationResponse<SimpleApnsPushNotification> response = mock(PushNotificationResponse.class);
when(response.isAccepted()).thenReturn(false);
when(response.getRejectionReason()).thenReturn("Unregistered");
when(response.getRejectionReason()).thenReturn(Optional.of("Unregistered"));
when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class)))
.thenAnswer((Answer) invocationOnMock -> new MockPushNotificationFuture<>(invocationOnMock.getArgument(0), response));
@ -232,7 +232,7 @@ public class APNSenderTest {
PushNotificationResponse<SimpleApnsPushNotification> response = mock(PushNotificationResponse.class);
when(response.isAccepted()).thenReturn(false);
when(response.getRejectionReason()).thenReturn("Unregistered");
when(response.getRejectionReason()).thenReturn(Optional.of("Unregistered"));
when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class)))
.thenAnswer((Answer) invocationOnMock -> new MockPushNotificationFuture<>(invocationOnMock.getArgument(0), response));
@ -327,7 +327,7 @@ public class APNSenderTest {
PushNotificationResponse<SimpleApnsPushNotification> response = mock(PushNotificationResponse.class);
when(response.isAccepted()).thenReturn(false);
when(response.getRejectionReason()).thenReturn("BadTopic");
when(response.getRejectionReason()).thenReturn(Optional.of("BadTopic"));
when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class)))
.thenAnswer((Answer) invocationOnMock -> new MockPushNotificationFuture<>(invocationOnMock.getArgument(0), response));