From d4e019c727afb720372a5fc58721ecf2e70115ed Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 10 May 2018 13:13:44 +0300 Subject: www: publish MessageReadEvent on thread view --- juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'juick-www/src/main/java') diff --git a/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java index 42bc5c49..01efd6c9 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java +++ b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java @@ -19,6 +19,7 @@ package com.juick.www.controllers; import com.juick.Message; import com.juick.Tag; import com.juick.formatters.PlainTextFormatter; +import com.juick.server.component.MessageReadEvent; import com.juick.server.util.HttpForbiddenException; import com.juick.server.util.HttpNotFoundException; import com.juick.server.util.UserUtils; @@ -30,6 +31,7 @@ import org.apache.commons.codec.CharEncoding; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.text.StringEscapeUtils; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -65,6 +67,8 @@ public class MessagesWWW { private PMQueriesService pmQueriesService; @Inject private CrosspostService crosspostService; + @Inject + private ApplicationEventPublisher applicationEventPublisher; void fillUserModel(ModelMap model, com.juick.User user, com.juick.User visitor) { model.addAttribute("user", user); @@ -508,6 +512,9 @@ public class MessagesWWW { } msg.VisitorCanComment = visitor.getUid() > 0; List replies = messagesService.getReplies(visitor, msg.getMid()); + if (!visitor.isAnonymous()) { + applicationEventPublisher.publishEvent(new MessageReadEvent(this, visitor, msg)); + } // this should be after getReplies to mark thread as read fillUserModel(model, user, visitor); if (visitor.getUid() > 0) { -- cgit v1.2.3