From d556681a773c8bd695ca58c325a132b3de2c0c44 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 12 Jul 2016 09:35:14 +0300 Subject: Push: using all user tokens for PMs --- .../main/java/com/juick/server/PushQueries.java | 28 +++++----------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'juick-core/src/main/java') 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 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 getAndroidRegID(JdbcTemplate sql, int uid) { + return sql.queryForList("SELECT regid FROM android WHERE user_id=?", String.class, uid); } public static List getAndroidTokens(JdbcTemplate sql, List 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 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 getWinPhoneURL(JdbcTemplate sql, int uid) { + return sql.queryForList("SELECT url FROM winphone WHERE user_id=?", String.class, uid); } public static List getWindowsTokens(JdbcTemplate sql, List 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 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 getAPNSToken(JdbcTemplate sql, int uid) { + return sql.queryForList("SELECT token from ios WHERE user_id=?", String.class, uid); } public static List getAPNSTokens(JdbcTemplate sql, List 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); } - } -- cgit v1.2.3