aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-02-17 10:17:14 +0300
committerGravatar Vitaly Takmazov2022-02-17 10:17:14 +0300
commitb38edd75f5142da515e46dbbc667162186a77653 (patch)
tree3a24f5f993d3b25fc5cfd02f92c680ed3ad77ade /src/main/java/com/juick/service
parentd95517f241f415c8603faac93f4efc8eea14dd15 (diff)
Do not allow to delete Telegram when it is the only social account
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/UserService.java2
-rw-r--r--src/main/java/com/juick/service/UserServiceImpl.java6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java
index c0428169..06637aee 100644
--- a/src/main/java/com/juick/service/UserService.java
+++ b/src/main/java/com/juick/service/UserService.java
@@ -185,4 +185,6 @@ public interface UserService {
String getJIDByHash(String hash);
boolean setJIDUser(String hash, int uid);
+
+ boolean canDeleteTelegramUser(User user);
}
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java
index e73f4ea3..fd42048c 100644
--- a/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/src/main/java/com/juick/service/UserServiceImpl.java
@@ -914,4 +914,10 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
public boolean setJIDUser(String hash, int uid) {
return getJdbcTemplate().update("UPDATE jids SET user_id=?,loginhash=NULL WHERE loginhash=?", uid, hash) > 0;
}
+
+ @Transactional(readOnly = true)
+ @Override
+ public boolean canDeleteTelegramUser(User user) {
+ return getEmails(user).size() > 0 || getFbCrossPostStatus(user.getUid()).isConnected() || getVkTokens(user.getUid()).isPresent();
+ }
}