aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-04-11 21:34:14 +0300
committerGravatar Vitaly Takmazov2018-04-11 21:34:14 +0300
commitad99117a15062a3819dad1f52a072e9694a954df (patch)
tree61b47950cca3adba91ef4f7c8ce80c1a1f8a531f /juick-www/src
parent47254ab8555162bc121c7b618fff42fc64b9454c (diff)
server: last read marker for threads
Diffstat (limited to 'juick-www/src')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/NewMessage.java2
-rw-r--r--juick-www/src/test/java/com/juick/WebAppTests.java13
3 files changed, 9 insertions, 8 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java
index e6662c4e..5bbea56b 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/MessagesWWW.java
@@ -540,7 +540,7 @@ public class MessagesWWW {
model.addAttribute("visitorSubscribed", messagesService.isSubscribed(visitor.getUid(), msg.getMid()));
model.addAttribute("visitorInBL", userService.isInBL(msg.getUser().getUid(), visitor.getUid()));
model.addAttribute("recomm", messagesService.getMessageRecommendations(msg.getMid()));
- List<com.juick.Message> replies = messagesService.getReplies(msg.getMid());
+ List<com.juick.Message> replies = messagesService.getReplies(visitor, msg.getMid());
List<Integer> blUIDs = new ArrayList<>();
for (Message reply : replies) {
diff --git a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
index 042a1b0f..6b97c7c4 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/NewMessage.java
@@ -147,7 +147,7 @@ public class NewMessage {
}
String attachmentType = StringUtils.isNotEmpty(attachmentFName.toString()) ? attachmentFName.toString().substring(attachmentFName.toString().length() - 3) : null;
- int ridnew = messagesService.createReply(mid, rid, visitor.getUid(), body, attachmentType);
+ int ridnew = messagesService.createReply(mid, rid, visitor, body, attachmentType);
subscriptionService.subscribeMessage(mid, visitor.getUid());
Message xmsg = new Message();
diff --git a/juick-www/src/test/java/com/juick/WebAppTests.java b/juick-www/src/test/java/com/juick/WebAppTests.java
index e383a0a9..37798d08 100644
--- a/juick-www/src/test/java/com/juick/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/WebAppTests.java
@@ -167,7 +167,7 @@ public class WebAppTests {
public void repliesList() throws IOException {
int mid = messagesService.createMessage(ugnich.getUid(), "hello", null, null);
IntStream.range(1, 15).forEach(i ->
- messagesService.createReply(mid, i-1, freefd.getUid(), String.valueOf(i-1), null ));
+ messagesService.createReply(mid, i-1, freefd, String.valueOf(i-1), null ));
HtmlPage threadPage = webClient.getPage(String.format("http://localhost:8080/ugnich/%d", mid));
assertThat(threadPage.getWebResponse().getStatusCode(), equalTo(200));
@@ -181,7 +181,7 @@ public class WebAppTests {
@Test
public void userShouldNotSeeReplyButtonToBannedUser() throws Exception {
int mid = messagesService.createMessage(ugnich.getUid(), "freefd bl me", null, null);
- messagesService.createReply(mid, 0, ugnich.getUid(), "yo", null);
+ messagesService.createReply(mid, 0, ugnich, "yo", null);
MvcResult loginResult = mockMvc.perform(post("/login")
.param("username", freefdName)
.param("password", freefdPassword)).andReturn();
@@ -198,7 +198,8 @@ public class WebAppTests {
privacyQueriesService.blacklistUser(freefd, ugnich);
assertThat(userService.isInBLAny(freefd.getUid(), ugnich.getUid()), equalTo(true));
int renhaId = userService.createUser("renha", "secret");
- messagesService.createReply(mid, 0, renhaId, "people", null);
+ messagesService.createReply(mid, 0, userService.getUserByUID(renhaId).orElseThrow(IllegalStateException::new),
+ "people", null);
threadPage = webClient.getPage(String.format("http://localhost:8080/ugnich/%d", mid));
assertThat(threadPage.getWebResponse().getStatusCode(), equalTo(200));
assertThat(threadPage.querySelectorAll(".msg-comment-target").isEmpty(), equalTo(true));
@@ -292,7 +293,7 @@ public class WebAppTests {
.param("body", String.format("D #%d/%d", mid, 3)))
.andExpect(status().isFound());
Thread.sleep(5000);
- assertThat(messagesService.getReplies(mid).size(), equalTo(2));
+ assertThat(messagesService.getReplies(ugnich, mid).size(), equalTo(2));
}
@Test
public void hashLoginShouldNotUseSession() throws Exception {
@@ -342,7 +343,7 @@ public class WebAppTests {
discussions = (HtmlPage) discussions.refresh();
assertThat(discussions.querySelectorAll("article").size(), is(2));
assertThat(discussions.querySelectorAll("article").get(0).getAttributes().getNamedItem("data-mid").getNodeValue(), is(String.valueOf(midNew)));
- messagesService.createReply(mid, 0, freefd.getUid(), "I'm replied", null);
+ messagesService.createReply(mid, 0, freefd, "I'm replied", null);
discussions = (HtmlPage) discussions.refresh();
assertThat(discussions.querySelectorAll("article").size(), is(2));
assertThat(discussions.querySelectorAll("article").get(0).getAttributes().getNamedItem("data-mid").getNodeValue(), is(String.valueOf(mid)));
@@ -358,7 +359,7 @@ public class WebAppTests {
assertThat(discussions.querySelectorAll("article").size(), is(20));
assertThat(discussions.querySelectorAll("article")
.get(19).getAttributes().getNamedItem("data-mid").getNodeValue(), is(String.valueOf(mid)));
- messagesService.createReply(midNew, 0, freefd.getUid(), "I'm replied", null);
+ messagesService.createReply(midNew, 0, freefd, "I'm replied", null);
discussions = (HtmlPage) discussions.refresh();
assertThat(discussions.querySelectorAll("article")
.get(0).getAttributes().getNamedItem("data-mid").getNodeValue(), is(String.valueOf(midNew)));