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 =
|
||||
case feed.site_url do
|
||||
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
|
||||
|
||||
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,
|
||||
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
|
||||
changeset =
|
||||
Feed.changeset(feed, %{
|
||||
favicon: favicon_data,
|
||||
favicon_url: to_string(favicon_url)
|
||||
})
|
||||
with %Feed{favicon_url: old_url} when old_url != favicon_url <- feed,
|
||||
{:ok, favicon_data} <- fetch_favicon_data(favicon_url) do
|
||||
changeset =
|
||||
Feed.changeset(feed, %{
|
||||
favicon: favicon_data,
|
||||
favicon_url: to_string(favicon_url)
|
||||
})
|
||||
|
||||
{:ok, _feed} = Repo.update(changeset)
|
||||
else
|
||||
_ ->
|
||||
:ok
|
||||
{:ok, _feed} = Repo.update(changeset)
|
||||
else
|
||||
_ ->
|
||||
:ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue