aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/api
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Messages.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/Messages.java b/juick-server/src/main/java/com/juick/server/api/Messages.java
index 7eb86284..666bab0a 100644
--- a/juick-server/src/main/java/com/juick/server/api/Messages.java
+++ b/juick-server/src/main/java/com/juick/server/api/Messages.java
@@ -20,12 +20,14 @@ package com.juick.server.api;
import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
+import com.juick.server.component.MessageReadEvent;
import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.UserUtils;
import com.juick.service.MessagesService;
import com.juick.service.TagService;
import com.juick.service.UserService;
import org.apache.commons.io.IOUtils;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -59,6 +61,8 @@ public class Messages {
private UserService userService;
@Inject
private TagService tagService;
+ @Inject
+ private ApplicationEventPublisher applicationEventPublisher;
// TODO: serialize image urls
@@ -148,6 +152,7 @@ public class Messages {
return FORBIDDEN;
} else {
List<com.juick.Message> replies = messagesService.getReplies(visitor, mid);
+ applicationEventPublisher.publishEvent(new MessageReadEvent(this, visitor, msg));
replies.add(0, msg);
return ResponseEntity.ok(replies);
}
@@ -159,6 +164,8 @@ public class Messages {
User visitor = UserUtils.getCurrentUser();
if (visitor.getUid() > 0) {
messagesService.setLastReadComment(visitor, mid, rid);
+ Message msg = messagesService.getMessage(mid);
+ applicationEventPublisher.publishEvent(new MessageReadEvent(this, visitor, msg));
return IOUtils.toByteArray(
Objects.requireNonNull(getClass().getClassLoader().getResource("Transparent.gif")));
}