aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-01 23:14:16 +0300
committerGravatar Vitaly Takmazov2016-12-01 23:23:10 +0300
commita797587800b68821a810fa3d833352dc272d42f7 (patch)
tree75bdd94be017b7c5adcf4551f717a7a872e81816 /juick-core/src/main/java/com
parent8b29dc19a288cf50246af0a3834d45e07da51642 (diff)
juick-server: fix serialization, vNext
Diffstat (limited to 'juick-core/src/main/java/com')
-rw-r--r--juick-core/src/main/java/com/juick/Message.java60
1 files changed, 44 insertions, 16 deletions
diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java
index 0bb75c57..702b74e5 100644
--- a/juick-core/src/main/java/com/juick/Message.java
+++ b/juick-core/src/main/java/com/juick/Message.java
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.juick.xml.adapters.SimpleDateAdapter;
+import org.apache.commons.lang3.StringUtils;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -42,28 +43,30 @@ public class Message implements Comparable {
private List<Tag> Tags = new ArrayList<>();
private Date date;
@XmlTransient
+ @JsonIgnore
public int TimeAgo = 0;
@JsonIgnore
private int privacy = 1;
@XmlTransient
+ @JsonIgnore
public boolean FriendsOnly = false;
@XmlTransient
+ @JsonIgnore
public boolean ReadOnly = false;
@XmlTransient
+ @JsonIgnore
public boolean Hidden = false;
@JsonIgnore
@XmlTransient
public boolean VisitorCanComment = true;
private int replies = 0;
- public String RepliesBy = null;
+ private String repliesBy;
private String attachmentType;
@XmlTransient
private Photo photo;
public String Video = null;
public Place Place = null;
- @XmlTransient
- public int Likes = 0;
- private boolean liked = false;
+ private int likes;
public List<Message> childs = new ArrayList<>();
private PM PM;
private Recommendation Recommendation;
@@ -90,8 +93,7 @@ public class Message implements Comparable {
photo = msg.photo;
Video = msg.Video;
Place = msg.Place;
- Likes = msg.Likes;
- setLiked(msg.isLiked());
+ setLikes(msg.getLikes());
childs = msg.childs;
PM = msg.PM;
Recommendation = msg.Recommendation;
@@ -138,7 +140,7 @@ public class Message implements Comparable {
return 0;
}
-
+ @JsonIgnore
public int getChildsCount() {
int cnt = childs.size();
for (Message child : childs) {
@@ -265,15 +267,6 @@ public class Message implements Comparable {
}
@XmlTransient
- public boolean isLiked() {
- return liked;
- }
-
- public void setLiked(boolean liked) {
- this.liked = liked;
- }
-
- @XmlTransient
public String getReplyQuote() {
return replyQuote;
}
@@ -336,4 +329,39 @@ public class Message implements Comparable {
public void setReplies(int replies) {
this.replies = replies;
}
+ @XmlTransient
+ public int getLikes() {
+ return likes;
+ }
+
+ public void setLikes(int likes) {
+ this.likes = likes;
+ }
+
+ @JsonProperty("repliesby")
+ public String getRepliesBy() {
+ return repliesBy;
+ }
+
+ public void setRepliesBy(String repliesBy) {
+ this.repliesBy = repliesBy;
+ }
+ @JsonProperty("photo")
+ @XmlTransient
+ public Photo getPhotoURLs() {
+ if (StringUtils.isNotBlank(attachmentType)) {
+ Photo photo = new Photo();
+ if (rid > 0) {
+ photo.setSmall(String.format("https://i.juick.com/photos-512/%d-%d.%s", mid, rid, attachmentType));
+ photo.setMedium(String.format("https://i.juick.com/photos-1024/%d-%d.%s", mid, rid, attachmentType));
+ photo.setThumbnail(String.format("https://i.juick.com/ps/%d-%d.%s", mid, rid, attachmentType));
+ } else {
+ photo.setSmall(String.format("https://i.juick.com/photos-512/%d.%s", mid, attachmentType));
+ photo.setMedium(String.format("https://i.juick.com/photos-1024/%d.%s", mid, attachmentType));
+ photo.setThumbnail(String.format("https://i.juick.com/ps/%d.%s", mid, attachmentType));
+ }
+ return photo;
+ }
+ return null;
+ }
}