aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-10 13:13:44 +0300
committerGravatar Vitaly Takmazov2018-05-10 13:15:50 +0300
commitd4e019c727afb720372a5fc58721ecf2e70115ed (patch)
treea931be638f1574d2f32b4a9e1ff008b26f8d7b00 /juick-www/src/main/java/com/juick/www
parent98eeee9a6e4b008fed5ed1aab58209b252d86b10 (diff)
www: publish MessageReadEvent on thread view
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java7
1 files changed, 7 insertions, 0 deletions
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<com.juick.Message> 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) {