diff options
author | Vitaly Takmazov | 2019-03-01 10:46:06 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-03-01 10:46:06 +0300 |
commit | 441bc18c6f072332920cee2473217bbab8e28055 (patch) | |
tree | 234fb9c100f4f43bee9aedade6c547a93e0817a2 /src/main/java | |
parent | 28912df439575842c6e5e34df9e212c5f6ff15ac (diff) |
api: return telegram and xmpp identifiers from service api endpoint
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/juick/server/api/Notifications.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/com/juick/server/api/Notifications.java b/src/main/java/com/juick/server/api/Notifications.java index 000a9f3b..ea1d5c54 100644 --- a/src/main/java/com/juick/server/api/Notifications.java +++ b/src/main/java/com/juick/server/api/Notifications.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2017, Juick + * Copyright (C) 2008-2019, Juick * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -24,14 +24,19 @@ import com.juick.User; import com.juick.model.AnonymousUser; import com.juick.server.util.HttpBadRequestException; import com.juick.server.util.HttpForbiddenException; +import com.juick.server.util.UserUtils; import com.juick.service.MessagesService; import com.juick.service.PushQueriesService; import com.juick.service.SubscriptionService; -import com.juick.server.util.UserUtils; +import com.juick.service.TelegramService; import com.juick.service.UserService; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; @@ -55,6 +60,8 @@ public class Notifications { private SubscriptionService subscriptionService; @Inject private UserService userService; + @Inject + private TelegramService telegramService; private User collectTokens(Integer uid) { @@ -63,6 +70,14 @@ public class Notifications { 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))); + List<ExternalToken> xmppJids = userService.getJIDsbyUID(uid).stream() + .map(jid -> new ExternalToken(null, "xmpp", jid, null)) + .collect(Collectors.toList()); + user.getTokens().addAll(xmppJids); + List<ExternalToken> tgIds = telegramService.getTelegramIdentifiers(Collections.singletonList(user)).stream() + .map(tgId -> new ExternalToken(null, "durov", String.valueOf(tgId), null)) + .collect(Collectors.toList()); + user.getTokens().addAll(tgIds); return user; } |