From 106c53cce6725591337773d412c0fb74eaf81ed8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 17 Apr 2023 16:01:28 +0300 Subject: Add/remove from whitelist on web --- .../java/com/juick/service/PrivacyQueriesService.java | 2 ++ .../com/juick/service/PrivacyQueriesServiceImpl.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'src/main/java/com/juick/service') 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; + } } -- cgit v1.2.3