Merge branch 'bugfix/mrf-reject-logging' into 'develop'
[akkoma] / lib / pleroma / http / adapter_helper / hackney.ex
1 defmodule Pleroma.HTTP.AdapterHelper.Hackney do
2 @behaviour Pleroma.HTTP.AdapterHelper
3
4 @defaults [
5 connect_timeout: 10_000,
6 recv_timeout: 20_000,
7 follow_redirect: true,
8 force_redirect: true,
9 pool: :federation
10 ]
11
12 @spec options(keyword(), URI.t()) :: keyword()
13 def options(connection_opts \\ [], %URI{} = uri) do
14 proxy = Pleroma.Config.get([:http, :proxy_url])
15
16 config_opts = Pleroma.Config.get([:http, :adapter], [])
17
18 @defaults
19 |> Keyword.merge(config_opts)
20 |> Keyword.merge(connection_opts)
21 |> add_scheme_opts(uri)
22 |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
23 end
24
25 defp add_scheme_opts(opts, _), do: opts
26
27 @spec get_conn(URI.t(), keyword()) :: {:ok, keyword()}
28 def get_conn(_uri, opts), do: {:ok, opts}
29 end