aboutsummaryrefslogtreecommitdiff
path: root/juick-server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Post.java14
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java3
2 files changed, 9 insertions, 8 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 17426072..f7298def 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
@@ -17,9 +17,11 @@
package com.juick.server.api;
+import com.juick.Status;
import com.juick.User;
import com.juick.server.EmailManager;
import com.juick.server.ServerManager;
+import com.juick.server.XMPPBot;
import com.juick.server.util.*;
import com.juick.service.MessagesService;
import com.juick.service.SubscriptionService;
@@ -78,6 +80,8 @@ public class Post {
private String imgDir;
@Value("${api_user:juick}")
private String serviceUser;
+ @Inject
+ XMPPBot bot;
@RequestMapping(value = "/post", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@@ -287,7 +291,7 @@ public class Post {
}
@PostMapping("/like")
@ResponseStatus(value = HttpStatus.OK)
- public void doPostRecomm(@RequestParam Integer mid) {
+ public Status doPostRecomm(@RequestParam Integer mid) {
com.juick.User visitor = UserUtils.getCurrentUser();
if (visitor.getUid() == 0) {
throw new HttpForbiddenException();
@@ -299,11 +303,7 @@ public class Post {
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);
+ String status = bot.commandRecommend(visitor, null, String.valueOf(mid));
+ return Status.getStatus(status);
}
}
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index c9556a98..d3dc7b58 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -660,7 +660,8 @@ public class ServerTests {
String freefdHash = userService.getHashByUID(freefd.getUid());
int freefdMid = messagesService.createMessage(freefd.getUid(), "to be not liked", null, null);
mockMvc.perform(post("/like?mid=" + mid + "&hash=" + freefdHash))
- .andExpect(status().isOk());
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.status", is("Message is added to your recommendations")));
mockMvc.perform(post("/like?mid=" + freefdMid + "&hash=" + freefdHash))
.andExpect(status().isForbidden());
}