aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-30 23:04:44 +0300
committerGravatar Vitaly Takmazov2018-09-30 23:04:44 +0300
commit2998e390b70618e214032e87c683664ac22b6a0f (patch)
treef9e6b7f9d232e85c500e396c2e2d78a89a9a4422 /juick-server/src/main/java/com/juick/server
parentecac3aa08c45953f09f5ab02a422cb12c6fef74f (diff)
subscribe over api
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Post.java19
1 files changed, 19 insertions, 0 deletions
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<Reaction> reactionsList() {