diff options
author | Vitaly Takmazov | 2018-03-28 22:28:33 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-03-28 22:31:43 +0300 |
commit | f6eb11a23ab645b187c5911ec762a3d6ca58140c (patch) | |
tree | 54f79790dc11a4e94487a5fce671f0514c092ccb /juick-server/src/main/java | |
parent | a41684e44da0021e2f8e653db28f1535e3941eb7 (diff) |
move like API to server
Diffstat (limited to 'juick-server/src/main/java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/Post.java | 23 |
1 files changed, 22 insertions, 1 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 e09de900..17426072 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 @@ -18,8 +18,8 @@ package com.juick.server.api; import com.juick.User; -import com.juick.server.ServerManager; import com.juick.server.EmailManager; +import com.juick.server.ServerManager; import com.juick.server.util.*; import com.juick.service.MessagesService; import com.juick.service.SubscriptionService; @@ -285,4 +285,25 @@ public class Post { throw new HttpForbiddenException(); } } + @PostMapping("/like") + @ResponseStatus(value = HttpStatus.OK) + public void doPostRecomm(@RequestParam Integer mid) { + com.juick.User visitor = UserUtils.getCurrentUser(); + if (visitor.getUid() == 0) { + 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(); + } + rocks.xmpp.core.stanza.model.Message xmsg = new rocks.xmpp.core.stanza.model.Message(); + xmsg.setType(rocks.xmpp.core.stanza.model.Message.Type.CHAT); + xmsg.setFrom(Jid.of(String.valueOf(visitor.getUid()), "uid.juick.com", "mail")); + xmsg.setTo(Jid.of("juick@juick.com/Juick")); + xmsg.setBody(String.format("! #%d", mid)); + serverManager.sendMessage(xmsg); + } } |