MastoAPI: Add emoji output.
authorRoger Braun <rbraun@Bobble.local>
Mon, 23 Oct 2017 14:27:51 +0000 (16:27 +0200)
committerRoger Braun <rbraun@Bobble.local>
Mon, 23 Oct 2017 14:27:51 +0000 (16:27 +0200)
lib/pleroma/web/mastodon_api/views/status_view.ex
test/support/factory.ex
test/web/mastodon_api/status_view_test.exs

index cce4f7217e85e4c95f0e662af57dc74c10670f7f..272f83b2ae6690acf9629d3b9f4a7b81400b10ef 100644 (file)
@@ -74,6 +74,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
     reply_to = Activity.get_create_activity_by_object_ap_id(object["inReplyTo"])
     reply_to_user = reply_to && User.get_cached_by_ap_id(reply_to.data["actor"])
 
+    emojis = (activity.data["object"]["emoji"] || [])
+    |> Enum.map(fn {name, url} -> %{ shortcode: name, url: url, static_url: url } end)
+
     %{
       id: activity.id,
       uri: object["id"],
@@ -99,7 +102,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
         name: "Web",
         website: nil
       },
-      language: nil
+      language: nil,
+      emojis: emojis
     }
   end
 
index f499024a2289073cdc86fb1244a9ea0912c18c24..33bacd40cdab61c9c63c70c7ad99cc1f9415913d 100644 (file)
@@ -26,7 +26,10 @@ defmodule Pleroma.Factory do
       "likes" => [],
       "like_count" => 0,
       "context" => "2hu",
-      "tag" => ["2hu"]
+      "tag" => ["2hu"],
+      "emoji" => %{
+        "2hu" => "corndog.png"
+      }
     }
 
     %Pleroma.Object{
index 1575b1d6e07c8865238afa23aa50f97a16eb8d3b..dc5cdfe9aab5ddf2e35722cc61f130f5d936d98a 100644 (file)
@@ -41,7 +41,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
         name: "Web",
         website: nil
       },
-      language: nil
+      language: nil,
+      emojis: [
+        %{
+          shortcode: "2hu",
+          url: "corndog.png",
+          static_url: "corndog.png"
+        }
+      ]
     }
 
     assert status == expected