diff options
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.java | 15 |
1 files changed, 14 insertions, 1 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 45b8f69c..05ce504f 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 @@ -21,11 +21,13 @@ import com.juick.Message; import com.juick.Status; import com.juick.Tag; import com.juick.User; +import com.juick.server.util.HttpBadRequestException; import com.juick.server.util.HttpForbiddenException; 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.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -34,8 +36,10 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; +import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Objects; /** * @author ugnich @@ -152,7 +156,16 @@ public class Messages { } return NOT_FOUND; } - + @GetMapping("/thread/mark_read/{mid}-{rid}.gif") + public byte[] markThreadRead(@PathVariable int mid, @PathVariable int rid) throws IOException { + User visitor = UserUtils.getCurrentUser(); + if (visitor.getUid() > 0) { + messagesService.setLastReadComment(visitor, mid, rid); + return IOUtils.toByteArray( + Objects.requireNonNull(getClass().getClassLoader().getResource("Transparent.gif"))); + } + throw new HttpBadRequestException(); + } @ApiIgnore @RequestMapping("/messages/set_privacy") @ResponseBody |