aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main/java/com')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java
index 9f9d699f..0bd5fe66 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/CrosspostServiceImpl.java
@@ -54,6 +54,21 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
&& getJdbcTemplate().update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", uid) > 0;
}
+ @Override
+ public void addFacebookState(String state) {
+ jdbcTemplate.update("INSERT INTO facebook(loginhash) VALUES(?)", state);
+ }
+
+ @Override
+ public boolean verifyFacebookState(String state) {
+ try {
+ return jdbcTemplate.queryForObject("SELECT COUNT(loginhash) FROM facebook WHERE loginhash=?",
+ Integer.class, state) == 1;
+ } catch (EmptyResultDataAccessException e) {
+ return false;
+ }
+ }
+
@Transactional(readOnly = true)
@Override
public Optional<Pair<String, String>> getFacebookTokens(final int uid) {
@@ -157,8 +172,8 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
@Transactional
@Override
public boolean createFacebookUser(long fbID, String loginhash, String token, String fbName, String fbLink) {
- return getJdbcTemplate().update("INSERT INTO facebook(fb_id,loginhash,access_token,fb_name,fb_link) VALUES (?,?,?,?,?)",
- fbID, loginhash, token, fbName, fbLink) > 0;
+ return getJdbcTemplate().update("UPDATE facebook SET fb_id=?, access_token=?, fb_name=?, fb_link=? WHERE loginhash=?",
+ fbID, token, fbName, fbLink, loginhash) > 0;
}
@Transactional