diff options
author | Alex Bitney | 2016-02-07 22:13:22 +0200 |
---|---|---|
committer | Alex Bitney | 2016-02-07 22:13:22 +0200 |
commit | e87db525cb547d30e9e87bf4e3fe7dc4bac332dd (patch) | |
tree | 08811226fad88a27618c1f44d293ae3b94143e14 /src/main/java/com/juick/PushComponent.java | |
parent | 45b3e65ac62a030f997a4cc5131c424e643d7722 (diff) | |
parent | 8012bef3931221133d656c22399c4c8ec582e52e (diff) |
Merge branch 'develop' of ssh://den.jabber.ru/var/lib/git/com.juick.http.www into sans_branch
Diffstat (limited to 'src/main/java/com/juick/PushComponent.java')
-rw-r--r-- | src/main/java/com/juick/PushComponent.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/com/juick/PushComponent.java b/src/main/java/com/juick/PushComponent.java index 3a96ff16..b77d2937 100644 --- a/src/main/java/com/juick/PushComponent.java +++ b/src/main/java/com/juick/PushComponent.java @@ -78,7 +78,7 @@ public class PushComponent implements JuickComponent { if (jmsg == null) { return; } - logger.info("Message to push: " + msg.toString()); + logger.info("Message to push: " + jmsg); List<User> subscribedUsers = new ArrayList<>(); boolean isPM = jmsg.getMID() == 0; boolean isReply = jmsg.getRID() > 0; @@ -101,16 +101,17 @@ public class PushComponent implements JuickComponent { } /*** ANDROID ***/ - List<String> regids; + List<String> regids = new ArrayList<>(); if (isPM) { - regids = new ArrayList<>(); String targetId = PushQueries.getAndroidRegID(sql, pmTo); if (targetId != null && !targetId.isEmpty()) { regids.add(targetId); } } else { List<Integer> uids = subscribedUsers.stream().map(User::getUID).collect(Collectors.toList()); - regids = PushQueries.getAndroidTokens(sql, uids); + if (uids.size() > 0) { + regids = PushQueries.getAndroidTokens(sql, uids); + } } if (!regids.isEmpty()) { @@ -134,16 +135,17 @@ public class PushComponent implements JuickComponent { } /*** WinPhone ***/ - List<String> urls; + List<String> urls = new ArrayList<>(); if (isPM) { - urls = new ArrayList<>(); String targetURL = PushQueries.getWinPhoneURL(sql, pmTo); if (!TextUtils.isEmpty(targetURL)) { urls.add(targetURL); } } else { - urls = PushQueries.getWindowsTokens(sql, - subscribedUsers.stream().map(User::getUID).collect(Collectors.toList())); + List<Integer> uids = subscribedUsers.stream().map(User::getUID).collect(Collectors.toList()); + if (uids.size() > 0) { + urls = PushQueries.getWindowsTokens(sql, uids); + } } @@ -181,16 +183,17 @@ public class PushComponent implements JuickComponent { } /*** iOS ***/ - List<String> tokens; + List<String> tokens = new ArrayList<>(); if (isPM) { - tokens = new ArrayList<>(); String targetToken = PushQueries.getAPNSToken(sql, pmTo); if (targetToken != null && !targetToken.isEmpty()) { tokens.add(targetToken); } } else { - tokens = PushQueries.getAPNSTokens(sql, - subscribedUsers.stream().map(User::getUID).collect(Collectors.toList())); + List<Integer> uids = subscribedUsers.stream().map(User::getUID).collect(Collectors.toList()); + if (uids.size() > 0) { + tokens = PushQueries.getAPNSTokens(sql, uids); + } } if (!tokens.isEmpty()) { ApnsService service = APNS.newService().withCert("/etc/juick/ios.p12", "juick") |