From c1e6e9dd484beb02dbd22f1b5ee3f86e8ca4aa0a Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 26 Jul 2018 22:55:51 +0300 Subject: mark threads read when banned replies exists --- .../src/main/java/com/juick/service/MessagesServiceImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'juick-server/src/main') diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java index a78c9203..75493377 100644 --- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -851,7 +851,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ new MapSqlParameterSource("mid", mid).addValue("uid", user.getUid()), new MessageMapper()); if (replies.size() > 0) { - setLastReadComment(user, mid, replies.stream().map(Message::getRid).max(Comparator.naturalOrder()).get()); + setRead(user, mid); } return replies; } @@ -987,6 +987,13 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ jdbcTemplate.update("UPDATE subscr_messages SET last_read_rid=GREATEST(?, last_read_rid) WHERE message_id=? AND suser_id=?", rid, mid, user.getUid()); } + @Transactional + @Override + public void setRead(User user, Integer mid) { + jdbcTemplate.update("UPDATE subscr_messages SET last_read_rid=(select replies from messages " + + "where messages.message_id=subscr_messages.message_id) WHERE message_id=? AND suser_id=?", + mid, user.getUid()); + } @Override public List getUnread(User user) { -- cgit v1.2.3