From 1a2830588131173d8fbfeb1fe03c466b4cf30e46 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 30 Nov 2016 16:49:11 +0300 Subject: juick-core: fix attachment serialization --- src/test/java/com/juick/json/MessageSerializer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/test/java/com/juick/json') diff --git a/src/test/java/com/juick/json/MessageSerializer.java b/src/test/java/com/juick/json/MessageSerializer.java index ebc3b0b0..38596a1a 100644 --- a/src/test/java/com/juick/json/MessageSerializer.java +++ b/src/test/java/com/juick/json/MessageSerializer.java @@ -18,6 +18,7 @@ package com.juick.json; import com.juick.Message; +import com.juick.Photo; import com.juick.Tag; import org.json.JSONArray; import org.json.JSONException; @@ -79,7 +80,12 @@ public class MessageSerializer extends JSONSerializer { } if (json.has("photo")) { - jmsg.Photo = json.getJSONObject("photo").getString("small"); + JSONObject obj = json.getJSONObject("photo"); + Photo photo = new Photo(); + photo.setSmall(obj.getString("small")); + photo.setMedium(obj.getString("medium")); + photo.setThumbnail(obj.getString("thumbnail")); + jmsg.setPhoto(photo); } return jmsg; @@ -123,8 +129,9 @@ public class MessageSerializer extends JSONSerializer { if (msg.Place != null) { json.put("place", placeSerializer.serialize(msg.Place)); } - if (msg.AttachmentType != null) { - String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : "") + "." + msg.AttachmentType; + if (msg.getAttachmentType() != null) { + json.put("attach", msg.getAttachmentType()); + String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : "") + "." + msg.getAttachmentType(); JSONObject photo = new JSONObject(); String protocol = getUriScheme() == URIScheme.Plain ? "http:" : "https:"; photo.put("thumbnail", protocol + "//i.juick.com/ps/" + fname); -- cgit v1.2.3