aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoreal <eal@waifu.club>2017-11-07 21:28:31 +0200
committereal <eal@waifu.club>2017-11-07 21:55:01 +0200
commitc6210183e1d52b22133560eb31306919470e7a73 (patch)
tree1cf0b6fc2525f2a9d86370d0d64e85c9bbbd2099 /lib
parented1eb5deea35ff2c3487ef550fad3a543a80cb32 (diff)
downloadpleroma-c6210183e1d52b22133560eb31306919470e7a73.tar.gz
Add mastodon API endpoint for custom emoji.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/formatter.ex1
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex13
-rw-r--r--lib/pleroma/web/router.ex1
-rw-r--r--lib/pleroma/web/twitter_api/controllers/util_controller.ex2
4 files changed, 15 insertions, 2 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index f062d9a58..00be839d8 100644
--- a/lib/pleroma/formatter.ex
+++ b/lib/pleroma/formatter.ex
@@ -125,6 +125,5 @@ defmodule Pleroma.Formatter do
def get_custom_emoji() do
@emoji
- |> Enum.into %{}
end
end
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index b1a54a4f1..96cf39f1a 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -61,6 +61,19 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
json(conn, response)
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
last = List.last(activities)
first = List.first(activities)
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index f96ec7213..b94056cd4 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -91,6 +91,7 @@ defmodule Pleroma.Web.Router do
pipe_through :api
get "/instance", MastodonAPIController, :masto_instance
post "/apps", MastodonAPIController, :create_app
+ get "/custom_emojis", MastodonAPIController, :custom_emojis
get "/timelines/public", MastodonAPIController, :public_timeline
get "/timelines/tag/:tag", MastodonAPIController, :hashtag_timeline
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
index 792ae2a64..de2abd4d1 100644
--- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -71,6 +71,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
end
def emoji(conn, _params) do
- json conn, Formatter.get_custom_emoji()
+ json conn, Enum.into(Formatter.get_custom_emoji(), %{})
end
end