aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java')
-rw-r--r--juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java37
1 files changed, 36 insertions, 1 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 ed1cd676..0f043292 100644
--- a/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/CrosspostServiceImpl.java
@@ -14,7 +14,6 @@ import java.util.Optional;
* Created by aalexeev on 11/13/16.
*/
@Repository
-@Transactional(readOnly = true)
public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostService {
@Inject
@@ -22,6 +21,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
super(jdbcTemplate, null);
}
+ @Transactional(readOnly = true)
@Override
public Optional<Pair<String, String>> getTwitterTokens(final int uid) {
List<Optional<Pair<String, String>>> list = getJdbcTemplate().query(
@@ -33,6 +33,14 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
Optional.empty() : list.get(0);
}
+ @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;
+ }
+
+ @Transactional(readOnly = true)
@Override
public Optional<String> getFacebookToken(final int uid) {
List<String> list = getJdbcTemplate().queryForList(
@@ -43,6 +51,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
Optional.empty() : Optional.of(list.get(0));
}
+ @Transactional(readOnly = true)
@Override
public ApplicationStatus getFbCrossPostStatus(final int uid) {
List<ApplicationStatus> list = getJdbcTemplate().query(
@@ -61,6 +70,24 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
new ApplicationStatus() : list.get(0);
}
+ @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,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)",
+ 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)
@Override
public String getTwitterName(final int uid) {
List<String> list = getJdbcTemplate().queryForList(
@@ -72,6 +99,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
"" : list.get(0);
}
+ @Transactional(readOnly = true)
@Override
public String getTelegramName(final int uid) {
List<String> list = getJdbcTemplate().queryForList(
@@ -83,6 +111,7 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
"" : list.get(0);
}
+ @Transactional(readOnly = true)
@Override
public Optional<Pair<String, String>> getVkTokens(final int uid) {
List<Optional<Pair<String, String>>> list = getJdbcTemplate().query(
@@ -93,4 +122,10 @@ public class CrosspostServiceImpl extends BaseJdbcService implements CrosspostSe
return list.isEmpty() ?
Optional.empty() : list.get(0);
}
+
+ @Transactional
+ @Override
+ public void deleteVKUser(Integer uid) {
+ getJdbcTemplate().update("DELETE FROM vk WHERE user_id=?", uid);
+ }
}