aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-05 15:17:24 +0300
committerGravatar Vitaly Takmazov2018-10-05 15:17:24 +0300
commit44f7ac629c5a5cf359c82bb96a263fedcb547a5e (patch)
tree63abf3a5a8a4a5648558861f13e6be09ec82a54f
parentbcfd8e147387025db75d5ee15168405aad62730e (diff)
Write user uri to replies
-rw-r--r--juick-common/src/main/java/com/juick/User.java2
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java6
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java4
3 files changed, 7 insertions, 5 deletions
diff --git a/juick-common/src/main/java/com/juick/User.java b/juick-common/src/main/java/com/juick/User.java
index 5615d96f4..8228230dd 100644
--- a/juick-common/src/main/java/com/juick/User.java
+++ b/juick-common/src/main/java/com/juick/User.java
@@ -18,6 +18,7 @@ package com.juick;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.annotation.Nonnull;
@@ -53,6 +54,7 @@ public class User {
public User() {
tokens = new ArrayList<>();
+ uri = URI.create(StringUtils.EMPTY);
}
@Override
diff --git a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
index 7412705e9..f59b40dda 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -176,9 +176,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
public int createReply(final int mid, final int rid, final User user, final String txt, final String attachment) {
int ridnew = getReplyIDIncrement(mid);
Date ts = Date.from(Instant.now());
- getJdbcTemplate().update("INSERT INTO replies(message_id, reply_id, user_id, replyto, attach, txt, ts, updated_at) " +
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
- mid, ridnew, user.getUid(), rid, attachment, txt, ts, ts);
+ getJdbcTemplate().update("INSERT INTO replies(message_id, reply_id, user_id, replyto, attach, txt, ts, updated_at, user_uri) " +
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ mid, ridnew, user.getUid(), rid, attachment, txt, ts, ts, user.getUri().toASCIIString());
if (ridnew > 0) {
getJdbcTemplate().update(
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 38845cd79..e3d7a3803 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
@@ -1323,8 +1323,8 @@ public class ServerTests {
jsonMapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
String jsonUser = jsonMapper.writeValueAsString(yyy);
Map<String, Object> user = JsonPath.read(jsonUser, "$");
- // only uid and name
- assertThat(user.keySet().size(), is(2));
+ // only uid, name and uri
+ assertThat(user.keySet().size(), is(3));
JAXBContext context = JAXBContext
.newInstance(User.class);