migrations/20200406100225_users_add_emoji: Fix tag to Emoji filtering, electric bongaloo

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-04-17 23:55:56 +02:00
parent 46f051048f
commit eb61564005
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE
2 changed files with 8 additions and 2 deletions

View File

@ -1430,7 +1430,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
emojis = emojis =
data data
|> Map.get("tag", []) |> Map.get("tag", [])
|> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end) |> Enum.filter(fn
%{"type" => t} -> t == "Emoji"
_ -> false
end)
|> Enum.reduce(%{}, fn %{"icon" => %{"url" => url}, "name" => name}, acc -> |> Enum.reduce(%{}, fn %{"icon" => %{"url" => url}, "name" => name}, acc ->
Map.put(acc, String.trim(name, ":"), url) Map.put(acc, String.trim(name, ":"), url)
end) end)

View File

@ -17,7 +17,10 @@ defmodule Pleroma.Repo.Migrations.UsersPopulateEmoji do
emoji = emoji =
user.source_data user.source_data
|> Map.get("tag", []) |> Map.get("tag", [])
|> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end) |> Enum.filter(fn
%{"type" => t} -> t == "Emoji"
_ -> false
end)
|> Enum.reduce(%{}, fn %{"icon" => %{"url" => url}, "name" => name}, acc -> |> Enum.reduce(%{}, fn %{"icon" => %{"url" => url}, "name" => name}, acc ->
Map.put(acc, String.trim(name, ":"), url) Map.put(acc, String.trim(name, ":"), url)
end) end)