From cab7e26aea1ac9518ff6c625340de2b809eaed50 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 23 Oct 2018 14:46:32 +0300 Subject: No need to subscribe on facebook and twitter magic users --- .../src/main/java/com/juick/service/CrosspostServiceImpl.java | 10 ++-------- .../src/main/java/com/juick/service/UserServiceImpl.java | 9 ++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java b/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java index 28e91ce7..d190faba 100644 --- a/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java @@ -50,8 +50,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe @Transactional @Override public boolean deleteTwitterToken(Integer uid) { - return getJdbcTemplate().update("DELETE FROM twitter WHERE user_id=?", uid) > 0 - && getJdbcTemplate().update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", uid) > 0; + return getJdbcTemplate().update("DELETE FROM twitter WHERE user_id=?", uid) > 0; } @Override @@ -117,18 +116,13 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe @Transactional @Override public boolean enableFBCrosspost(Integer uid) { - return getJdbcTemplate().update("UPDATE facebook SET crosspost=1 WHERE user_id=?", uid) > 0 - && getJdbcTemplate().update( - "INSERT INTO subscr_users(user_id,suser_id) VALUES (?,5863)", - uid) > 0; + return getJdbcTemplate().update("UPDATE facebook SET crosspost=1 WHERE user_id=?", uid) > 0; } @Transactional @Override public void disableFBCrosspost(Integer uid) { getJdbcTemplate().update("UPDATE facebook SET crosspost=0 WHERE user_id=?", uid); - // TODO: stop using magic numbers for system users - getJdbcTemplate().update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", uid); } @Transactional(readOnly = true) diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java index ead71e2f..0eae1ae3 100644 --- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java @@ -526,15 +526,10 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Override public boolean linkTwitterAccount( final User user, final String accessToken, final String accessTokenSecret, final String screenName) { - if (getJdbcTemplate().update("INSERT INTO twitter(user_id,access_token,access_token_secret,uname) " + + return getJdbcTemplate().update("INSERT INTO twitter(user_id,access_token,access_token_secret,uname) " + "VALUES (?,?,?,?)" + " ON DUPLICATE KEY UPDATE access_token=?,access_token_secret=?,uname=?", - user.getUid(), accessToken, accessTokenSecret, screenName, accessToken, accessTokenSecret, screenName) > 0) { - return getJdbcTemplate().update("INSERT INTO subscr_users(user_id,suser_id) " + - "VALUES (?,1741)", user.getUid()) > 0; - } - return false; - + user.getUid(), accessToken, accessTokenSecret, screenName, accessToken, accessTokenSecret, screenName) > 0; } @Transactional(readOnly = true) -- cgit v1.2.3