aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/juick/server/UserQueries.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java
index d1313715..470f3c8e 100644
--- a/src/main/java/com/juick/server/UserQueries.java
+++ b/src/main/java/com/juick/server/UserQueries.java
@@ -17,6 +17,8 @@
*/
package com.juick.server;
+import com.juick.User;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -574,6 +576,33 @@ public class UserQueries {
return users;
}
+ public static boolean linkTwitterAccount(Connection sql, User user, String accessToken,
+ String accessTokenSecret, String screenName) {
+ try {
+ PreparedStatement stmt =
+ sql.prepareStatement("INSERT INTO twitter(user_id,access_token,access_token_secret,uname) " +
+ "VALUES (?,?,?,?)" +
+ " ON DUPLICATE KEY UPDATE access_token=?,access_token_secret=?,uname=?;");
+ stmt.setInt(1, user.UID);
+ stmt.setString(2, accessToken);
+ stmt.setString(3, accessTokenSecret);
+ stmt.setString(4, screenName);
+ stmt.setString(5, accessToken);
+ stmt.setString(6, accessTokenSecret);
+ stmt.setString(7, screenName);
+ if (stmt.execute()) {
+ PreparedStatement stmt2 =
+ sql.prepareStatement("INSERT INTO subscr_users(user_id,suser_id,jid) " +
+ "VALUES (?,1741,'juick\\@twitter.juick.com')");
+ stmt2.setInt(1, user.UID);
+ return stmt2.execute();
+ }
+ } catch (SQLException e) {
+
+ }
+ return false;
+ }
+
public static int getStatsIRead(Connection sql, int uid) {
return SQLHelpers.getInt(sql, "SELECT COUNT(*) FROM subscr_users WHERE suser_id=?", uid, 0);
}