2020-10-20 09:25:02 +02:00
|
|
|
defmodule Mobilizon.Service.HTTP.RichMediaPreviewClient do
|
|
|
|
@moduledoc """
|
2020-10-21 10:42:04 +02:00
|
|
|
Tesla HTTP Basic Client that fetches HTML to extract metadata preview
|
2020-10-20 09:25:02 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
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
|