|> Map.put("content", emoji)
|> Map.put("type", "EmojiReact")
else
- emojo = Emoji.get(emoji)
- path = emojo |> Map.get(:file)
- url = "#{Endpoint.url()}#{path}"
-
- data
- |> Map.put("content", emoji)
- |> Map.put("type", "EmojiReact")
- |> Map.put("tag", [
- %{}
- |> Map.put("id", url)
- |> Map.put("type", "Emoji")
- |> Map.put("name", emojo.code)
- |> Map.put(
- "icon",
+ with %{} = emojo <- Emoji.get(emoji) do
+ path = emojo |> Map.get(:file)
+ url = "#{Endpoint.url()}#{path}"
+
+ data
+ |> Map.put("content", emoji)
+ |> Map.put("type", "EmojiReact")
+ |> Map.put("tag", [
%{}
- |> Map.put("type", "Image")
- |> Map.put("url", url)
- )
- ])
+ |> Map.put("id", url)
+ |> Map.put("type", "Emoji")
+ |> Map.put("name", emojo.code)
+ |> Map.put(
+ "icon",
+ %{}
+ |> Map.put("type", "Image")
+ |> Map.put("url", url)
+ )
+ ])
+ else
+ _ -> {:error, "Emoji does not exist"}
+ end
end
{:ok, data, meta}
end
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
defp filter(reactions, _), do: reactions
assert to_string(activity.id) == id
assert result["pleroma"]["emoji_reactions"] == [
- %{"name" => "☕", "count" => 1, "me" => true}
+ %{"name" => "☕", "count" => 1, "me" => true, "url" => nil}
]
# Reacting with a non-emoji
{: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
|> get("/api/v1/pleroma/statuses/#{activity.id}/reactions/🎅")
|> json_response_and_validate_schema(200)