mobilizon/lib/service/http/rich_media_preview_client.ex
Thomas Citharel 85aa9df4f8
Fix webfinger not following redirections by using a custom dedicated Tesla client
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-10-21 11:20:15 +02:00

23 lines
495 B
Elixir

defmodule Mobilizon.Service.HTTP.RichMediaPreviewClient do
@moduledoc """
Tesla HTTP Basic Client that fetches HTML to extract metadata preview
"""
use Tesla
alias Mobilizon.Config
@default_opts [
recv_timeout: 20_000
]
adapter(Tesla.Adapter.Hackney, @default_opts)
@user_agent Config.instance_user_agent()
plug(Tesla.Middleware.FollowRedirects)
plug(Tesla.Middleware.Timeout, timeout: 10_000)
plug(Tesla.Middleware.Headers, [{"User-Agent", @user_agent}])
end