From 2998e390b70618e214032e87c683664ac22b6a0f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 30 Sep 2018 23:04:44 +0300 Subject: subscribe over api --- .../src/main/java/com/juick/server/api/Post.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'juick-server/src/main/java/com') diff --git a/juick-server/src/main/java/com/juick/server/api/Post.java b/juick-server/src/main/java/com/juick/server/api/Post.java index b36f324a..74a29de7 100644 --- a/juick-server/src/main/java/com/juick/server/api/Post.java +++ b/juick-server/src/main/java/com/juick/server/api/Post.java @@ -173,6 +173,25 @@ public class Post { return Status.getStatus(status.getText()); } + @PostMapping("/api/subscribe") + @ResponseStatus(value = HttpStatus.OK) + public Status doPostSubscribe(@RequestParam Integer mid) throws Exception { + com.juick.User visitor = UserUtils.getCurrentUser(); + if (visitor.isAnonymous()) { + throw new HttpForbiddenException(); + } + com.juick.Message msg = messagesService.getMessage(mid); + if (msg == null) { + throw new HttpNotFoundException(); + } + if (msg.getUser().getUid() == visitor.getUid()) { + throw new HttpForbiddenException(); + } + CommandResult status = commandsManager.processCommand(visitor, String.format("S #%d", mid), + URI.create(StringUtils.EMPTY)); + return Status.getStatus(status.getText()); + } + @GetMapping("/api/reactions") @ResponseStatus(value = HttpStatus.OK) public List reactionsList() { -- cgit v1.2.3