projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'feature/autofollowing' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
rich_media
/
helpers.ex
diff --git
a/lib/pleroma/web/rich_media/helpers.ex
b/lib/pleroma/web/rich_media/helpers.ex
index b7852c6e3fec025ec84bbe42511b4085ed11a6f7..d67b594b57dd10a2edce2bc9362e8ff1b7dcd219 100644
(file)
--- a/
lib/pleroma/web/rich_media/helpers.ex
+++ b/
lib/pleroma/web/rich_media/helpers.ex
@@
-9,14
+9,15
@@
defmodule Pleroma.Web.RichMedia.Helpers do
alias Pleroma.Object
alias Pleroma.Web.RichMedia.Parser
alias Pleroma.Object
alias Pleroma.Web.RichMedia.Parser
- @
rich_media_
options [
+ @options [
pool: :media,
pool: :media,
- max_body: 2_000_000
+ max_body: 2_000_000,
+ recv_timeout: 2_000
]
@spec validate_page_url(URI.t() | binary()) :: :ok | :error
defp validate_page_url(page_url) when is_binary(page_url) do
]
@spec validate_page_url(URI.t() | binary()) :: :ok | :error
defp validate_page_url(page_url) when is_binary(page_url) do
- validate_tld =
Pleroma.
Config.get([Pleroma.Formatter, :validate_tld])
+ validate_tld = Config.get([Pleroma.Formatter, :validate_tld])
page_url
|> Linkify.Parser.url?(validate_tld: validate_tld)
page_url
|> Linkify.Parser.url?(validate_tld: validate_tld)
@@
-56,7
+57,6
@@
defmodule Pleroma.Web.RichMedia.Helpers do
def fetch_data_for_object(object) do
with true <- Config.get([:rich_media, :enabled]),
def fetch_data_for_object(object) do
with true <- Config.get([:rich_media, :enabled]),
- false <- object.data["sensitive"] || false,
{:ok, page_url} <-
HTML.extract_first_external_url_from_object(object),
:ok <- validate_page_url(page_url),
{:ok, page_url} <-
HTML.extract_first_external_url_from_object(object),
:ok <- validate_page_url(page_url),
@@
-86,18
+86,8
@@
defmodule Pleroma.Web.RichMedia.Helpers do
def rich_media_get(url) do
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
def rich_media_get(url) do
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
- options =
- if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
- Keyword.merge(@rich_media_options,
- recv_timeout: 2_000,
- with_body: true
- )
- else
- @rich_media_options
- end
-
head_check =
head_check =
- case Pleroma.HTTP.head(url, headers,
adapter:
options) do
+ case Pleroma.HTTP.head(url, headers,
@
options) do
# If the HEAD request didn't reach the server for whatever reason,
# we assume the GET that comes right after won't either
{:error, _} = e ->
# If the HEAD request didn't reach the server for whatever reason,
# we assume the GET that comes right after won't either
{:error, _} = e ->
@@
-112,7
+102,7
@@
defmodule Pleroma.Web.RichMedia.Helpers do
:ok
end
:ok
end
- with :ok <- head_check, do: Pleroma.HTTP.get(url, headers,
adapter:
options)
+ with :ok <- head_check, do: Pleroma.HTTP.get(url, headers,
@
options)
end
defp check_content_type(headers) do
end
defp check_content_type(headers) do
@@
-128,7
+118,7
@@
defmodule Pleroma.Web.RichMedia.Helpers do
end
end
end
end
- @max_body @
rich_media_
options[:max_body]
+ @max_body @options[:max_body]
defp check_content_length(headers) do
case List.keyfind(headers, "content-length", 0) do
{_, maybe_content_length} ->
defp check_content_length(headers) do
case List.keyfind(headers, "content-length", 0) do
{_, maybe_content_length} ->