aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar mykhailo.dubovskyi2018-04-18 15:57:53 +0300
committerGravatar Vitaly Takmazov2018-04-20 11:03:47 +0300
commit842e903d5b987dd23e82a423bddae75acdea0c9c (patch)
tree59eabfb9969b6cbe00703674f8d3ddb7d2e029e0 /juick-server/src/main/java/com/juick/server
parentef1c674b0dc1979e46e970ad67ccc7a9bb67b001 (diff)
Like -> Reaction
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Messages.java1
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Post.java27
3 files changed, 29 insertions, 3 deletions
diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
index 5bbfec91..31496407 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -358,8 +358,8 @@ public class TelegramBotManager implements NotificationListener {
.forEach(c -> telegramNotify(c, String.format("%s recommends your [post](%s)",
MessageUtils.getMarkdownUser(liker), formatUrl(message)),null));
telegramService.getTelegramIdentifiers(subscribers)
- .forEach(c -> telegramNotify(c, String.format("%s recommends you someone's [post](%s)",
- MessageUtils.getMarkdownUser(liker), formatUrl(message)), null));
+ .forEach(c -> telegramNotify(c, String.format("%s recommends you someone's [post](%s)",
+ MessageUtils.getMarkdownUser(liker), formatUrl(message)), null));
}
@Override
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 8142a179..c6600e2b 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
@@ -90,6 +90,7 @@ public class Messages {
@RequestParam(required = false) String popular,
@RequestParam(required = false) String media,
@RequestParam(required = false) String tag) {
+
User visitor = UserUtils.getCurrentUser();
int vuid = visitor.getUid();
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 9dd42db0..5a027ece 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
@@ -22,8 +22,8 @@ import com.juick.User;
import com.juick.server.CommandsManager;
import com.juick.server.EmailManager;
import com.juick.server.XMPPConnection;
-import com.juick.server.util.*;
import com.juick.server.helpers.CommandResult;
+import com.juick.server.util.*;
import com.juick.service.MessagesService;
import com.juick.service.SubscriptionService;
import com.juick.service.UserService;
@@ -44,6 +44,7 @@ import javax.inject.Inject;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
+import javax.validation.constraints.NotNull;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -235,6 +236,7 @@ public class Post {
throw new HttpForbiddenException();
}
}
+
@PostMapping("/like")
@ResponseStatus(value = HttpStatus.OK)
public Status doPostRecomm(@RequestParam Integer mid) throws Exception {
@@ -253,4 +255,27 @@ public class Post {
URI.create(StringUtils.EMPTY));
return Status.getStatus(status.getText());
}
+
+ @PostMapping("/react")
+ @ResponseStatus(value = HttpStatus.OK)
+ public Status doPostReact(@RequestParam Integer mid,@RequestParam @NotNull int reactionId){
+
+ logger.info("got reaction with type: {}", reactionId);
+ 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();
+ }
+
+ MessagesService.RecommendStatus recommendStatus = messagesService.likeMessage(mid,msg.getUser().getUid(),
+ reactionId);
+
+ return recommendStatus == MessagesService.RecommendStatus.Error ? Status.ERROR :Status.OK;
+ }
}