forked from AkkomaGang/akkoma
fix emoji controller tests
This commit is contained in:
parent
142646426e
commit
c3ed86cd1e
3 changed files with 31 additions and 20 deletions
|
@ -64,7 +64,7 @@ def emoji_react(actor, object, emoji) do
|
||||||
|> Map.put("content", emoji)
|
|> Map.put("content", emoji)
|
||||||
|> Map.put("type", "EmojiReact")
|
|> Map.put("type", "EmojiReact")
|
||||||
else
|
else
|
||||||
emojo = Emoji.get(emoji)
|
with %{} = emojo <- Emoji.get(emoji) do
|
||||||
path = emojo |> Map.get(:file)
|
path = emojo |> Map.get(:file)
|
||||||
url = "#{Endpoint.url()}#{path}"
|
url = "#{Endpoint.url()}#{path}"
|
||||||
|
|
||||||
|
@ -83,6 +83,9 @@ def emoji_react(actor, object, emoji) do
|
||||||
|> Map.put("url", url)
|
|> Map.put("url", url)
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
else
|
||||||
|
_ -> {:error, "Emoji does not exist"}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
{:ok, data, meta}
|
{:ok, data, meta}
|
||||||
|
|
|
@ -67,7 +67,7 @@ def filter_allowed_users(reactions, user, with_muted) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter(reactions, %{emoji: emoji}) when is_binary(emoji) do
|
defp filter(reactions, %{emoji: emoji}) when is_binary(emoji) do
|
||||||
Enum.filter(reactions, fn [e, _] -> e == emoji end)
|
Enum.filter(reactions, fn [e, _, _] -> e == emoji end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter(reactions, _), do: reactions
|
defp filter(reactions, _), do: reactions
|
||||||
|
|
|
@ -31,7 +31,7 @@ test "PUT /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
|
||||||
assert to_string(activity.id) == id
|
assert to_string(activity.id) == id
|
||||||
|
|
||||||
assert result["pleroma"]["emoji_reactions"] == [
|
assert result["pleroma"]["emoji_reactions"] == [
|
||||||
%{"name" => "☕", "count" => 1, "me" => true}
|
%{"name" => "☕", "count" => 1, "me" => true, "url" => nil}
|
||||||
]
|
]
|
||||||
|
|
||||||
# Reacting with a non-emoji
|
# Reacting with a non-emoji
|
||||||
|
@ -181,7 +181,15 @@ test "GET /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
|
||||||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅")
|
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅")
|
||||||
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||||
|
|
||||||
assert [%{"name" => "🎅", "count" => 1, "accounts" => [represented_user], "me" => false}] =
|
assert [
|
||||||
|
%{
|
||||||
|
"name" => "🎅",
|
||||||
|
"count" => 1,
|
||||||
|
"accounts" => [represented_user],
|
||||||
|
"me" => false,
|
||||||
|
"url" => nil
|
||||||
|
}
|
||||||
|
] =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/pleroma/statuses/#{activity.id}/reactions/🎅")
|
|> get("/api/v1/pleroma/statuses/#{activity.id}/reactions/🎅")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
Loading…
Reference in a new issue