From de2cc2db73a5de42d9bfaeb92604f28abe2a328a Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 24 Oct 2017 17:18:29 +0300 Subject: crosspost: refactoring * spring-social * get tokens via service api --- .../main/java/com/juick/api/controllers/Notifications.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'juick-api/src/main/java/com/juick/api/controllers/Notifications.java') diff --git a/juick-api/src/main/java/com/juick/api/controllers/Notifications.java b/juick-api/src/main/java/com/juick/api/controllers/Notifications.java index c08689aa..2a55844c 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/Notifications.java +++ b/juick-api/src/main/java/com/juick/api/controllers/Notifications.java @@ -19,7 +19,7 @@ package com.juick.api.controllers; import com.juick.Message; import com.juick.Status; -import com.juick.DeviceRegistration; +import com.juick.ExternalToken; import com.juick.User; import com.juick.server.helpers.AnonymousUser; import com.juick.server.util.HttpBadRequestException; @@ -58,9 +58,9 @@ public class Notifications { private User collectTokens(Integer uid) { User user = userService.getUserByUID(uid).orElse(AnonymousUser.INSTANCE); - pushQueriesService.getGCMRegID(uid).forEach(t -> user.getDevices().add(new DeviceRegistration("gcm", t))); - pushQueriesService.getAPNSToken(uid).forEach(t -> user.getDevices().add(new DeviceRegistration("apns", t))); - pushQueriesService.getMPNSURL(uid).forEach(t -> user.getDevices().add(new DeviceRegistration("mpns", t))); + pushQueriesService.getGCMRegID(uid).forEach(t -> user.getTokens().add(new ExternalToken(null, "gcm", t, null))); + pushQueriesService.getAPNSToken(uid).forEach(t -> user.getTokens().add(new ExternalToken(null, "apns", t, null))); + pushQueriesService.getMPNSURL(uid).forEach(t -> user.getTokens().add(new ExternalToken(null, "mpns", t, null))); return user; } @@ -98,7 +98,7 @@ public class Notifications { @RequestMapping(value = "/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public Status doDelete( - @RequestBody List list) throws IOException { + @RequestBody List list) throws IOException { User visitor = UserUtils.getCurrentUser(); // FIXME: it is possible to delete other user's tokens if ((visitor.getUid() == 0) || !(visitor.getName().equals("juick"))) { @@ -125,7 +125,7 @@ public class Notifications { @RequestMapping(value = "/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public Status doPut( - @RequestBody List list) throws IOException { + @RequestBody List list) throws IOException { User visitor = UserUtils.getCurrentUser(); if (visitor.getUid() == 0) { throw new HttpForbiddenException(); -- cgit v1.2.3