Merge branch 'mastodon-emoji-endpoint' into 'develop'

Add mastodon API endpoint for custom emoji.

See merge request pleroma/pleroma!8
This commit is contained in:
lambda 2017-11-07 20:01:15 +00:00
commit be67db5547
4 changed files with 15 additions and 2 deletions

View File

@ -125,6 +125,5 @@ def get_emoji(text) do
def get_custom_emoji() do def get_custom_emoji() do
@emoji @emoji
|> Enum.into %{}
end end
end end

View File

@ -61,6 +61,19 @@ def masto_instance(conn, _params) do
json(conn, response) json(conn, response)
end end
def custom_emojis(conn, _params) do
mastodon_emoji = Pleroma.Formatter.get_custom_emoji()
|> Enum.map(fn {shortcode, relative_url} ->
url = to_string URI.merge(Web.base_url(), relative_url)
%{
"shortcode" => shortcode,
"static_url" => url,
"url" => url
}
end)
json conn, mastodon_emoji
end
defp add_link_headers(conn, method, activities) do defp add_link_headers(conn, method, activities) do
last = List.last(activities) last = List.last(activities)
first = List.first(activities) first = List.first(activities)

View File

@ -91,6 +91,7 @@ def user_fetcher(username) do
pipe_through :api pipe_through :api
get "/instance", MastodonAPIController, :masto_instance get "/instance", MastodonAPIController, :masto_instance
post "/apps", MastodonAPIController, :create_app post "/apps", MastodonAPIController, :create_app
get "/custom_emojis", MastodonAPIController, :custom_emojis
get "/timelines/public", MastodonAPIController, :public_timeline get "/timelines/public", MastodonAPIController, :public_timeline
get "/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline get "/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline

View File

@ -71,6 +71,6 @@ def version(conn, _params) do
end end
def emoji(conn, _params) do def emoji(conn, _params) do
json conn, Formatter.get_custom_emoji() json conn, Enum.into(Formatter.get_custom_emoji(), %{})
end end
end end