Repository: steemit/hivemind

Issue:
serve full json_metadata
Currently hivemind serves a filtered version of json_metadata; for compatibility it should just continue serve full json for now, as per the steemd API it replaces.

Discussion:

Patch:
diff --git a/hive/utils/post.py b/hive/utils/post.py
index a1e5a14..562b518 100644
--- a/hive/utils/post.py
+++ b/hive/utils/post.py
@@ -19,10 +19,13 @@ def post_basic(post):
         pass
 
     thumb_url = ''
-    if md and 'image' in md and md['image']:
-        thumb_url = safe_img_url(first(md['image'])) or ''
-        if thumb_url:
-            md['image'] = [thumb_url]
+    if md and 'image' in md:
+        if md['image']:
+            if not isinstance(md['image'], list):
+                md['image'] = [md['image']]
+            md['image'] = list(filter(None, map(safe_img_url, md['image'])))
+        if md['image']:
+            thumb_url = md['image'][0]
         else:
             del md['image']
 


Test patch:
diff --git a/tests/utils/test_utils_post.py b/tests/utils/test_utils_post.py
index 21b0dca..58332e9 100644
--- a/tests/utils/test_utils_post.py
+++ b/tests/utils/test_utils_post.py
@@ -62,7 +62,7 @@ POST_1 = {
     "curator_payout_value": "0.000 SBD",
     "depth": 0,
     "id": 4437869,
-    "json_metadata": "{\"tags\":[\"spam\"],\"image\":[\"https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg\"],\"app\":\"steemit/0.1\",\"format\":\"markdown\"}",
+    "json_metadata": "{\"tags\":[\"spam\"],\"image\":[\"ddd\", \"https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg\",\"https://example.com/image.jpg\"],\"app\":\"steemit/0.1\",\"format\":\"markdown\"}",
     "last_payout": "2017-06-27T15:53:51",
     "last_update": "2017-06-20T15:53:51",
     "max_accepted_payout": "1000000.000 SBD",
@@ -91,7 +91,7 @@ POST_1 = {
 
 def test_post_basic():
     ret = post_basic(POST_1)
-    expect = {'json_metadata': {'tags': ['spam'], 'image': ['https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg'], 'app': 'steemit/0.1', 'format': 'markdown'},
+    expect = {'json_metadata': {'tags': ['spam'], 'image': ['https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg', 'https://example.com/image.jpg'], 'app': 'steemit/0.1', 'format': 'markdown'},
               'image': 'https://pbs.twimg.com/media/DBgNm3jXoAAioyE.jpg',
               'tags': {'spam'},
               'is_nsfw': False,