diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/juick/server/UserQueries.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index 7e3a212b..ff819629 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -622,4 +622,29 @@ public class UserQueries { public static int getStatsReplies(Connection sql, int uid) { return SQLHelpers.getInt(sql, "SELECT COUNT(*) FROM replies WHERE user_id=?", uid, 0); } + + public enum ActiveStatus { + Inactive, + Active + } + + public static boolean setActiveStatusForJID(Connection sql, String JID, ActiveStatus jidStatus) { + User user = getUserByJID(sql, JID); + if (user != null) { + PreparedStatement preparedStatement = null; + try { + preparedStatement = sql.prepareStatement( + "UPDATE jids SET active=? WHERE user_id=? AND jid=?"); + int newStatus = jidStatus == ActiveStatus.Active ? 1 : 0; + preparedStatement.setInt(1, newStatus); + preparedStatement.setInt(2, user.UID); + preparedStatement.setString(3, JID); + return preparedStatement.executeUpdate() >= 0; + } catch (SQLException e) { + e.printStackTrace(); + } finally { + Utils.finishSQL(null, preparedStatement); + } + } + } } |