aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-01 23:01:22 +0300
committerGravatar Vitaly Takmazov2016-12-01 23:01:22 +0300
commit8b29dc19a288cf50246af0a3834d45e07da51642 (patch)
treee5cd5f6e7611d002fd5809c3138dbe39f6602583
parentbdd36eb9858d0dccd94827de55e36767095be048 (diff)
juick-core: fix replies serialization
-rw-r--r--juick-core/src/main/java/com/juick/Message.java14
-rw-r--r--juick-server/src/main/java/com/juick/server/MessagesQueries.java2
-rw-r--r--juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/PageTemplates.java4
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java8
-rw-r--r--src/test/java/com/juick/json/MessageSerializer.java6
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java2
7 files changed, 23 insertions, 15 deletions
diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java
index d3f28e22..0bb75c57 100644
--- a/juick-core/src/main/java/com/juick/Message.java
+++ b/juick-core/src/main/java/com/juick/Message.java
@@ -54,8 +54,7 @@ public class Message implements Comparable {
@JsonIgnore
@XmlTransient
public boolean VisitorCanComment = true;
- @XmlTransient
- public int Replies = 0;
+ private int replies = 0;
public String RepliesBy = null;
private String attachmentType;
@XmlTransient
@@ -86,7 +85,7 @@ public class Message implements Comparable {
FriendsOnly = msg.FriendsOnly;
ReadOnly = msg.ReadOnly;
Hidden = msg.Hidden;
- Replies = msg.Replies;
+ setReplies(msg.getReplies());
attachmentType = msg.attachmentType;
photo = msg.photo;
Video = msg.Video;
@@ -328,4 +327,13 @@ public class Message implements Comparable {
public void setAttachmentType(String attachmentType) {
this.attachmentType = attachmentType;
}
+
+ @XmlTransient
+ public int getReplies() {
+ return replies;
+ }
+
+ public void setReplies(int replies) {
+ this.replies = replies;
+ }
}
diff --git a/juick-server/src/main/java/com/juick/server/MessagesQueries.java b/juick-server/src/main/java/com/juick/server/MessagesQueries.java
index 36d311df..b028ec34 100644
--- a/juick-server/src/main/java/com/juick/server/MessagesQueries.java
+++ b/juick-server/src/main/java/com/juick/server/MessagesQueries.java
@@ -61,7 +61,7 @@ public class MessagesQueries {
msg.ReadOnly = rs.getBoolean(9);
msg.setPrivacy(rs.getInt(10));
msg.FriendsOnly = msg.getPrivacy() < 0;
- msg.Replies = rs.getInt(11);
+ msg.setReplies(rs.getInt(11));
msg.setAttachmentType(rs.getString(12));
if (rs.getDouble(13) != 0) {
msg.Place = new com.juick.Place();
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 bd044866..537219d6 100644
--- a/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/juick-server/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -60,7 +60,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
msg.ReadOnly = rs.getBoolean(9);
msg.setPrivacy(rs.getInt(10));
msg.FriendsOnly = msg.getPrivacy() < 0;
- msg.Replies = rs.getInt(11);
+ msg.setReplies(rs.getInt(11));
msg.setAttachmentType(rs.getString(12));
if (rs.getDouble(13) != 0) {
msg.Place = new com.juick.Place();
diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java
index 504a4b8b..685c81fe 100644
--- a/juick-www/src/main/java/com/juick/www/PageTemplates.java
+++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java
@@ -363,8 +363,8 @@ public class PageTemplates {
if (msg.Likes > 0) {
out.print("<a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\" class=\"likes\"><i data-icon=\"ei-heart\" data-size=\"s\"></i>&nbsp;" + msg.Likes + "</a>");
}
- if (msg.Replies > 0) {
- out.print("<a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\" class=\"replies\"><i data-icon=\"ei-comment\" data-size=\"s\"></i>&nbsp;" + msg.Replies + "</a>");
+ if (msg.getReplies() > 0) {
+ out.print("<a href=\"/" + msg.getUser().getName() + "/" + msg.getMid() + "\" class=\"replies\"><i data-icon=\"ei-comment\" data-size=\"s\"></i>&nbsp;" + msg.getReplies() + "</a>");
}
out.println("</nav>");
out.print("</article>");
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java
index d9763709..7bef76ab 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionRouter.java
@@ -228,11 +228,11 @@ public class ConnectionRouter extends Connection implements Runnable {
}
txt += jmsg.getText() + "\n\n";
txt += "#" + jmsg.getMid();
- if (jmsg.Replies > 0) {
- if (jmsg.Replies % 10 == 1 && jmsg.Replies % 100 != 11) {
- txt += " (" + jmsg.Replies + " reply)";
+ if (jmsg.getReplies() > 0) {
+ if (jmsg.getReplies() % 10 == 1 && jmsg.getReplies() % 100 != 11) {
+ txt += " (" + jmsg.getReplies() + " reply)";
} else {
- txt += " (" + jmsg.Replies + " replies)";
+ txt += " (" + jmsg.getReplies() + " replies)";
}
}
txt += " http://juick.com/" + jmsg.getMid();
diff --git a/src/test/java/com/juick/json/MessageSerializer.java b/src/test/java/com/juick/json/MessageSerializer.java
index 38596a1a..b49c991a 100644
--- a/src/test/java/com/juick/json/MessageSerializer.java
+++ b/src/test/java/com/juick/json/MessageSerializer.java
@@ -76,7 +76,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
}
if (json.has("replies")) {
- jmsg.Replies = json.getInt("replies");
+ jmsg.setReplies(json.getInt("replies"));
}
if (json.has("photo")) {
@@ -123,8 +123,8 @@ public class MessageSerializer extends JSONSerializer<Message> {
if (msg.getTags() != null && msg.getTags().size() > 0) {
json.put("tags", new JSONArray(msg.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
}
- if (msg.Replies > 0) {
- json.put("replies", msg.Replies);
+ if (msg.getReplies() > 0) {
+ json.put("replies", msg.getReplies());
}
if (msg.Place != null) {
json.put("place", placeSerializer.serialize(msg.Place));
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 1d777d62..1c13c1a7 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -85,7 +85,7 @@ public class ApiTests {
int rid = MessagesQueries.createReply(jdbc, msg2.getMid(), 0, ugnich.getUid(), "bla-bla", null);
assertEquals(1, rid);
Message msg3 = MessagesQueries.getMessage(jdbc, mid2);
- assertEquals(1, msg3.Replies);
+ assertEquals(1, msg3.getReplies());
assertEquals("weather", msg3.getTags().get(0).getName());
assertEquals(ugnich.getUid(), UserQueries.checkPassword(jdbc, ugnich.getName(), "x"));
assertEquals(-1, UserQueries.checkPassword(jdbc, ugnich.getName(), "xy"));