Merge branch 'fix/emoji-api-nonsense' into 'develop'

Change response format of /api/pleroma/emoji so it makes sense

See merge request pleroma/pleroma!1038
This commit is contained in:
lambda 2019-04-10 06:22:51 +00:00
commit c8440b5e0c
3 changed files with 34 additions and 14 deletions

View File

@ -10,7 +10,29 @@ Request parameters can be passed via [query strings](https://en.wikipedia.org/wi
* Authentication: not required * Authentication: not required
* Params: none * Params: none
* Response: JSON * Response: JSON
* Example response: `[{"kalsarikannit_f":{"tags":["Finmoji"],"image_url":"/finmoji/128px/kalsarikannit_f-128.png"}},{"perkele":{"tags":["Finmoji"],"image_url":"/finmoji/128px/perkele-128.png"}},{"blobdab":{"tags":["SomeTag"],"image_url":"/emoji/blobdab.png"}},"happiness":{"tags":["Finmoji"],"image_url":"/finmoji/128px/happiness-128.png"}}]` * Example response:
```json
{
"girlpower": {
"tags": [
"Finmoji"
],
"image_url": "/finmoji/128px/girlpower-128.png"
},
"education": {
"tags": [
"Finmoji"
],
"image_url": "/finmoji/128px/education-128.png"
},
"finnishlove": {
"tags": [
"Finmoji"
],
"image_url": "/finmoji/128px/finnishlove-128.png"
}
}
```
* Note: Same data as Mastodon APIs `/api/v1/custom_emojis` but in a different format * Note: Same data as Mastodon APIs `/api/v1/custom_emojis` but in a different format
## `/api/pleroma/follow_import` ## `/api/pleroma/follow_import`

View File

@ -286,8 +286,9 @@ def emoji(conn, _params) do
emoji = emoji =
Emoji.get_all() Emoji.get_all()
|> Enum.map(fn {short_code, path, tags} -> |> Enum.map(fn {short_code, path, tags} ->
%{short_code => %{image_url: path, tags: String.split(tags, ",")}} {short_code, %{image_url: path, tags: String.split(tags, ",")}}
end) end)
|> Enum.into(%{})
json(conn, emoji) json(conn, emoji)
end end

View File

@ -193,22 +193,19 @@ test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} d
describe "/api/pleroma/emoji" do describe "/api/pleroma/emoji" do
test "returns json with custom emoji with tags", %{conn: conn} do test "returns json with custom emoji with tags", %{conn: conn} do
[emoji | _body] = emoji =
conn conn
|> get("/api/pleroma/emoji") |> get("/api/pleroma/emoji")
|> json_response(200) |> json_response(200)
[key] = Map.keys(emoji) assert Enum.all?(emoji, fn
{_key,
%{ %{
^key => %{ "image_url" => url,
"image_url" => url, "tags" => tags
"tags" => tags }} ->
} is_binary(url) and is_list(tags)
} = emoji end)
assert is_binary(url)
assert is_list(tags)
end end
end end