aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-12 09:35:14 +0300
committerGravatar Vitaly Takmazov2016-07-12 09:35:14 +0300
commitd556681a773c8bd695ca58c325a132b3de2c0c44 (patch)
tree874bf475de4cbd67976f659b7a1852230831caa6 /juick-core/src/main
parent39d3d0a4693bc985641b4e2372e0010b26ff0030 (diff)
Push: using all user tokens for PMs
Diffstat (limited to 'juick-core/src/main')
-rw-r--r--juick-core/src/main/java/com/juick/server/PushQueries.java28
1 files changed, 6 insertions, 22 deletions
diff --git a/juick-core/src/main/java/com/juick/server/PushQueries.java b/juick-core/src/main/java/com/juick/server/PushQueries.java
index f4c98fcf..904b3c0d 100644
--- a/juick-core/src/main/java/com/juick/server/PushQueries.java
+++ b/juick-core/src/main/java/com/juick/server/PushQueries.java
@@ -4,12 +4,10 @@
*/
package com.juick.server;
-import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import java.util.List;
-import java.util.Optional;
/**
*
@@ -17,13 +15,8 @@ import java.util.Optional;
*/
public class PushQueries {
- public static Optional<String> getAndroidRegID(JdbcTemplate sql, int uid) {
- try {
- return Optional.of(sql.queryForObject("SELECT regid FROM android WHERE user_id=?", String.class, uid));
- } catch (EmptyResultDataAccessException e) {
- return Optional.empty();
- }
-
+ public static List<String> getAndroidRegID(JdbcTemplate sql, int uid) {
+ return sql.queryForList("SELECT regid FROM android WHERE user_id=?", String.class, uid);
}
public static List<String> getAndroidTokens(JdbcTemplate sql, List<Integer> uids) {
@@ -31,12 +24,8 @@ public class PushQueries {
"ON (users.id=android.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")", String.class);
}
- public static Optional<String> getWinPhoneURL(JdbcTemplate sql, int uid) {
- try {
- return Optional.of(sql.queryForObject("SELECT url FROM winphone WHERE user_id=?", String.class, uid));
- } catch (EmptyResultDataAccessException e) {
- return Optional.empty();
- }
+ public static List<String> getWinPhoneURL(JdbcTemplate sql, int uid) {
+ return sql.queryForList("SELECT url FROM winphone WHERE user_id=?", String.class, uid);
}
public static List<String> getWindowsTokens(JdbcTemplate sql, List<Integer> uids) {
@@ -44,17 +33,12 @@ public class PushQueries {
"ON (users.id=winphone.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")", String.class);
}
- public static Optional<String> getAPNSToken(JdbcTemplate sql, int uid) {
- try {
- return Optional.of(sql.queryForObject("SELECT token from ios WHERE user_id=?", String.class, uid));
- } catch (EmptyResultDataAccessException e) {
- return Optional.empty();
- }
+ public static List<String> getAPNSToken(JdbcTemplate sql, int uid) {
+ return sql.queryForList("SELECT token from ios WHERE user_id=?", String.class, uid);
}
public static List<String> getAPNSTokens(JdbcTemplate sql, List<Integer> uids) {
return sql.queryForList("SELECT token FROM ios INNER JOIN users " +
"ON (users.id=ios.user_id) WHERE users.id IN (" + StringUtils.collectionToCommaDelimitedString(uids) + ")", String.class);
}
-
}