Don't fetch favicon for Gemini protocol feeds
This commit is contained in:
parent
12bb742be9
commit
198ca0345b
|
@ -13,28 +13,31 @@ defmodule Frenzy.Task.FetchFavicon do
|
||||||
site_url =
|
site_url =
|
||||||
case feed.site_url do
|
case feed.site_url do
|
||||||
url when is_binary(url) ->
|
url when is_binary(url) ->
|
||||||
url
|
URI.parse(url)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
%URI{URI.parse(feed.feed_url) | path: nil, query: nil, fragment: nil} |> URI.to_string()
|
%URI{URI.parse(feed.feed_url) | path: nil, query: nil, fragment: nil}
|
||||||
end
|
end
|
||||||
|
|
||||||
Logger.debug("Fetching favicon for #{site_url}")
|
if site_url.scheme in ["http", "https"] do
|
||||||
|
Logger.debug("Fetching favicon for #{site_url}")
|
||||||
|
|
||||||
favicon_url = fetch_favicon_url_from_webpage(site_url) || URI.merge(site_url, "/favicon.ico")
|
favicon_url =
|
||||||
|
fetch_favicon_url_from_webpage(site_url) || URI.merge(site_url, "/favicon.ico")
|
||||||
|
|
||||||
with %Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
|
with %Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
|
||||||
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
|
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
|
||||||
changeset =
|
changeset =
|
||||||
Feed.changeset(feed, %{
|
Feed.changeset(feed, %{
|
||||||
favicon: favicon_data,
|
favicon: favicon_data,
|
||||||
favicon_url: to_string(favicon_url)
|
favicon_url: to_string(favicon_url)
|
||||||
})
|
})
|
||||||
|
|
||||||
{:ok, _feed} = Repo.update(changeset)
|
{:ok, _feed} = Repo.update(changeset)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
:ok
|
:ok
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue