From cf3a5d8c979b114fceef43b35541b941bcbd62a1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 17 Apr 2023 15:00:14 +0300 Subject: Private posts --- src/main/java/com/juick/service/MessagesService.java | 3 +++ src/main/java/com/juick/service/MessagesServiceImpl.java | 6 ++++++ src/main/java/com/juick/service/UserService.java | 1 + 3 files changed, 10 insertions(+) (limited to 'src/main/java/com/juick/service') diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java index a6b6e2e2..91788a3c 100644 --- a/src/main/java/com/juick/service/MessagesService.java +++ b/src/main/java/com/juick/service/MessagesService.java @@ -162,4 +162,7 @@ public interface MessagesService { void setMessageProperty(Integer mid, Integer rid, String key, String value); Optional> findMessageByProperty(String key, String value); + + @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true) + void setFriendsOnly(Integer mid, Boolean friendsOnly); } diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 53f2407c..85dadd77 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -1175,4 +1175,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ } return Optional.empty(); } + @Transactional + @Override + public void setFriendsOnly(Integer mid, Boolean friendsOnly) { + int privacy = friendsOnly ? -1 : 1; + jdbcTemplate.update("UPDATE messages SET privacy=? WHERE message_id=?", privacy, mid); + } } diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java index ec5beb13..53acdfab 100644 --- a/src/main/java/com/juick/service/UserService.java +++ b/src/main/java/com/juick/service/UserService.java @@ -201,5 +201,6 @@ public interface UserService { boolean deleteToken(String serviceType, String token); + @CacheEvict(value = "users_by_name", allEntries = true) void setPremium(Integer uid, boolean isPremium); } -- cgit v1.2.3