diff options
author | Vitaly Takmazov | 2023-04-17 16:01:28 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-04-17 16:01:28 +0300 |
commit | 106c53cce6725591337773d412c0fb74eaf81ed8 (patch) | |
tree | fe07a0136c63787d6e5f53349af16541faebaf89 /src/main/java/com/juick/service | |
parent | cf3a5d8c979b114fceef43b35541b941bcbd62a1 (diff) |
Add/remove from whitelist on web
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r-- | src/main/java/com/juick/service/PrivacyQueriesService.java | 2 | ||||
-rw-r--r-- | src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/PrivacyQueriesService.java b/src/main/java/com/juick/service/PrivacyQueriesService.java index 68c157f6..f1b9915d 100644 --- a/src/main/java/com/juick/service/PrivacyQueriesService.java +++ b/src/main/java/com/juick/service/PrivacyQueriesService.java @@ -35,4 +35,6 @@ public interface PrivacyQueriesService { @CacheEvict(value = { "discussions", "messages", "replies" }, allEntries = true) PrivacyResult blacklistTag(User user, Tag tag); + + PrivacyResult whiteListUser(User user, User target); } diff --git a/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java b/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java index 437c9f8c..d954df09 100644 --- a/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java +++ b/src/main/java/com/juick/service/PrivacyQueriesServiceImpl.java @@ -60,4 +60,20 @@ public class PrivacyQueriesServiceImpl extends BaseJdbcService implements Privac return PrivacyResult.Added; } + + @Override + public PrivacyResult whiteListUser(User user, User target) { + int result = getJdbcTemplate().update( + "DELETE FROM wl_users WHERE user_id = ? AND wl_user_id = ?", + user.getUid(), target.getUid()); + + if (result > 0) + return PrivacyResult.Removed; + + getJdbcTemplate().update( + "INSERT INTO wl_users(user_id, wl_user_id) VALUES (?, ?)", + user.getUid(), target.getUid()); + + return PrivacyResult.Added; + } } |