Send favicons in Fever API

This commit is contained in:
Shadowfacts 2019-11-10 14:55:35 -05:00
parent fb6a441acd
commit 899cd5afff
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 19 additions and 2 deletions

View File

@ -158,9 +158,26 @@ defmodule FrenzyWeb.FeverController do
end
end
defp favicons(res, _user, %{"favicons" => _}) do
defp favicons(res, user, %{"favicons" => _}) do
favicons =
user.groups
|> Enum.flat_map(& &1.feeds)
|> Enum.map(fn feed ->
case feed.favicon do
nil ->
nil
favicon ->
%{
id: feed.id,
data: favicon |> String.trim_leading("data:")
}
end
end)
|> Enum.reject(&is_nil/1)
res
|> Map.put(:favicons, [])
|> Map.put(:favicons, favicons)
end
defp favicons(res, _, _), do: res