From 0761ac90a89cf826e100ec7cea660b38288fab9b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 22 Sep 2017 17:13:15 +0300 Subject: api: /messages/notifications --- .../src/main/java/com/juick/api/controllers/Messages.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'juick-api') diff --git a/juick-api/src/main/java/com/juick/api/controllers/Messages.java b/juick-api/src/main/java/com/juick/api/controllers/Messages.java index bc324996..3037f3a1 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/Messages.java +++ b/juick-api/src/main/java/com/juick/api/controllers/Messages.java @@ -34,6 +34,9 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.Collections; import java.util.List; @@ -131,6 +134,13 @@ public class Messages { return ResponseEntity.ok(messagesService.getMessages(mids)); } + @GetMapping("/messages/notifications") + public ResponseEntity> getNotifications( + @RequestParam(required = false) Long before + ) { + User visitor = UserUtils.getCurrentUser(); + return ResponseEntity.ok(messagesService.getNotifications(visitor, LocalDateTime.ofInstant(Instant.ofEpochMilli(before), ZoneId.systemDefault()))); + } @RequestMapping("/thread") public ResponseEntity> getThread( @RequestParam(defaultValue = "0") int mid) { -- cgit v1.2.3