aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-09 14:29:47 +0300
committerGravatar Vitaly Takmazov2018-10-09 14:29:47 +0300
commit3bbaae4589de56da9ab09360aa28a3cd12198471 (patch)
tree436fd6436e582d0de7cbb0b3373e3d2d9fcc97ee /juick-notifications
parent9eb0139ed6a0e823a0863c8734278e620587627f (diff)
MessageReadEvent refactoring
Diffstat (limited to 'juick-notifications')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/APNSManager.java28
-rw-r--r--juick-notifications/src/main/java/com/juick/components/NotificationsManager.java4
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) {