MastoAPI: Add emoji output.

This commit is contained in:
Roger Braun 2017-10-23 16:27:51 +02:00
parent 38f3908c14
commit 64bc38e009
3 changed files with 17 additions and 3 deletions

View file

@ -74,6 +74,9 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
reply_to = Activity.get_create_activity_by_object_ap_id(object["inReplyTo"]) 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"]) 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, id: activity.id,
uri: object["id"], uri: object["id"],
@ -99,7 +102,8 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
name: "Web", name: "Web",
website: nil website: nil
}, },
language: nil language: nil,
emojis: emojis
} }
end end

View file

@ -26,7 +26,10 @@ def note_factory do
"likes" => [], "likes" => [],
"like_count" => 0, "like_count" => 0,
"context" => "2hu", "context" => "2hu",
"tag" => ["2hu"] "tag" => ["2hu"],
"emoji" => %{
"2hu" => "corndog.png"
}
} }
%Pleroma.Object{ %Pleroma.Object{

View file

@ -41,7 +41,14 @@ test "a note activity" do
name: "Web", name: "Web",
website: nil website: nil
}, },
language: nil language: nil,
emojis: [
%{
shortcode: "2hu",
url: "corndog.png",
static_url: "corndog.png"
}
]
} }
assert status == expected assert status == expected