Don't fetch favicon for Gemini protocol feeds

This commit is contained in:
Shadowfacts 2020-07-18 22:13:51 -04:00
parent 12bb742be9
commit 198ca0345b
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 18 additions and 15 deletions

View File

@ -13,15 +13,17 @@ 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
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
@ -37,6 +39,7 @@ defmodule Frenzy.Task.FetchFavicon do
:ok
end
end
end
@spec fetch_favicon_url_from_webpage(url :: String.t()) :: String.t()