diff options
author | Vitaly Takmazov | 2015-11-30 20:26:45 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2015-11-30 20:26:45 +0300 |
commit | b9a14509d5512c59cb923396e646f3d4337ea069 (patch) | |
tree | a53f9ea0b4e63b854b4dfabe84a22f495f116cd9 /src/main/java/com/juick/server/PushQueries.java | |
parent | c49596ab050db2f30d97d6f7129b8239bb4f33e3 (diff) | |
parent | caf7d95837e0dae5056b2b297a47928f0adc5900 (diff) |
Merge branch 'develop' of ssh://den.jabber.ru:2205/var/lib/git/com.juick.server into develop
Diffstat (limited to 'src/main/java/com/juick/server/PushQueries.java')
-rw-r--r-- | src/main/java/com/juick/server/PushQueries.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/PushQueries.java b/src/main/java/com/juick/server/PushQueries.java index 84f42722..bf7505ca 100644 --- a/src/main/java/com/juick/server/PushQueries.java +++ b/src/main/java/com/juick/server/PushQueries.java @@ -9,6 +9,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.List; /** * @@ -65,4 +66,29 @@ public class PushQueries { } return urls; } + + public static String getAPNSToken(Connection sql, int uid) { + return SQLHelpers.getString(sql, "SELECT token from ios WHERE user_id=?", uid); + } + + public static List<String> getAPNSSubscribers(Connection sql, int uid) { + List<String> urls = new ArrayList<String>(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT token FROM ios INNER JOIN subscr_users ON (subscr_users.user_id=? AND ios.user_id=subscr_users.suser_id)"); + stmt.setInt(1, uid); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + urls.add(rs.getString(1)); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return urls; + } } |