diff options
Diffstat (limited to 'juick-notifications/src/main/java/com')
-rw-r--r-- | juick-notifications/src/main/java/com/juick/components/APNSManager.java | 28 | ||||
-rw-r--r-- | juick-notifications/src/main/java/com/juick/components/NotificationsManager.java | 4 |
2 files changed, 16 insertions, 16 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/APNSManager.java b/juick-notifications/src/main/java/com/juick/components/APNSManager.java index 3eaf3c93..2c7cfce4 100644 --- a/juick-notifications/src/main/java/com/juick/components/APNSManager.java +++ b/juick-notifications/src/main/java/com/juick/components/APNSManager.java @@ -95,22 +95,20 @@ public class APNSManager implements NotificationListener { @Override public void processMessageReadEvent(MessageReadEvent messageReadEvent) { - List<User> users = messageReadEvent.getUsers(); + User user = messageReadEvent.getUser(); ApnsPayloadBuilder apnsPayloadBuilder = new ApnsPayloadBuilder(); - users.forEach(user -> { - apnsPayloadBuilder.setBadgeNumber(user.getUnreadCount()); - String payload = apnsPayloadBuilder.buildWithDefaultMaximumLength(); - user.getTokens().stream().filter(t -> t.getType().equals("apns")) - .map(ExternalToken::getToken).forEach(token -> { - Future<PushNotificationResponse<SimpleApnsPushNotification>> notification = apns.sendNotification( - new SimpleApnsPushNotification(token, topic, payload)); - notification.addListener((PushNotificationResponseListener<SimpleApnsPushNotification>) future -> { - if (future.isSuccess()) { - processAPNSResponse(token, future.getNow()); - } else { - logger.warn("APNS error ", future.cause()); - } - }); + apnsPayloadBuilder.setBadgeNumber(user.getUnreadCount()); + String payload = apnsPayloadBuilder.buildWithDefaultMaximumLength(); + user.getTokens().stream().filter(t -> t.getType().equals("apns")) + .map(ExternalToken::getToken).forEach(token -> { + Future<PushNotificationResponse<SimpleApnsPushNotification>> notification = apns.sendNotification( + new SimpleApnsPushNotification(token, topic, payload)); + notification.addListener((PushNotificationResponseListener<SimpleApnsPushNotification>) future -> { + if (future.isSuccess()) { + processAPNSResponse(token, future.getNow()); + } else { + logger.warn("APNS error ", future.cause()); + } }); }); } diff --git a/juick-notifications/src/main/java/com/juick/components/NotificationsManager.java b/juick-notifications/src/main/java/com/juick/components/NotificationsManager.java index be97ea40..fce0bed7 100644 --- a/juick-notifications/src/main/java/com/juick/components/NotificationsManager.java +++ b/juick-notifications/src/main/java/com/juick/components/NotificationsManager.java @@ -103,7 +103,9 @@ public class NotificationsManager extends TextWebSocketHandler { jmsg.getUser().getUid()), HttpMethod.GET, null, new ParameterizedTypeReference<List<User>>() { }).getBody(); - applicationEventPublisher.publishEvent(new MessageReadEvent(this, users, jmsg)); + users.forEach(user -> { + applicationEventPublisher.publishEvent(new MessageReadEvent(this, user, jmsg)); + }); } public void addInvalidGCMToken(String token) { |