aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-04-26 18:33:58 +0300
committerGravatar Vitaly Takmazov2024-04-26 18:33:58 +0300
commite00dc41afada45c9cc0cab882d5e67f8d0c980f2 (patch)
treedaf9e4f9de024f51dc3a581f38bf1d34986ce74f /src/main/java/com/juick
parent57fae6b2d4e2f94e49a3b809a47ef4abc2a1ef80 (diff)
"Mark read" buttonmark_read
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/service/MessagesService.java3
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java9
-rw-r--r--src/main/java/com/juick/www/api/Messages.java6
3 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java
index f2321b2a..707a04c3 100644
--- a/src/main/java/com/juick/service/MessagesService.java
+++ b/src/main/java/com/juick/service/MessagesService.java
@@ -143,6 +143,9 @@ public interface MessagesService {
void setLastReadComment(User user, Integer mid, Integer rid);
@CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true, condition = "{ #user.uid != 0 }")
+ void setAllRead(User user);
+
+ @CacheEvict(value = { "discover", "discussions", "messages", "replies" }, allEntries = true, condition = "{ #user.uid != 0 }")
void setRead(User user, Integer mid);
List<Integer> getUnread(User user);
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 940cdaba..105b86cf 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -1084,6 +1084,15 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
rid, mid, user.getUid());
}
+ @Override
+ public void setAllRead(User user) {
+ jdbcTemplate.update("""
+ update subscr_messages set last_read_rid=total.replies FROM messages
+ INNER JOIN messages total on total.message_id=messages.message_id
+ WHERE messages.message_id=subscr_messages.message_id AND subscr_messages.suser_id=?
+ """, user.getUid());
+ }
+
@Transactional
@Override
public void setRead(User user, Integer mid) {
diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java
index 969bef4f..5a90bf0b 100644
--- a/src/main/java/com/juick/www/api/Messages.java
+++ b/src/main/java/com/juick/www/api/Messages.java
@@ -210,6 +210,12 @@ public class Messages {
}
throw new HttpBadRequestException();
}
+ @PostMapping("/api/messages/mark_read")
+ public void markRead(@Parameter(hidden = true) User visitor) {
+ if (!visitor.isAnonymous()) {
+ messagesService.setAllRead(visitor);
+ }
+ }
@PostMapping("/api/messages/set_privacy")
public void togglePrivacy(@Parameter(hidden = true) User visitor, @RequestParam Integer mid) {
if (visitor.isPremium() || visitor.isAdmin()) {