Use WhatsApp user-agent for rich media by default
Related https://gitlab.com/soapbox-pub/rebased/-/issues/180
This commit is contained in:
parent
0d08f049e9
commit
e8f414b3d0
3 changed files with 20 additions and 1 deletions
|
@ -6,6 +6,11 @@ For changes to Pleroma, see `CHANGELOG.md`
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Link previews not working for some websites. Let rich media user-agent be configurable (with `:pleroma, :rich_media, user_agent: "whatever"`).
|
||||||
|
|
||||||
## [3.0.0] - 2022-05-24
|
## [3.0.0] - 2022-05-24
|
||||||
|
|
||||||
Based on Pleroma 2.4 develop.
|
Based on Pleroma 2.4 develop.
|
||||||
|
|
|
@ -53,3 +53,6 @@
|
||||||
|
|
||||||
# Background migration performance
|
# Background migration performance
|
||||||
config :pleroma, :delete_context_objects, sleep_interval_ms: 3_000
|
config :pleroma, :delete_context_objects, sleep_interval_ms: 3_000
|
||||||
|
|
||||||
|
# Pretend to be WhatsApp because some sites don't return link previews otherwise
|
||||||
|
config :pleroma, :rich_media, user_agent: "WhatsApp/2"
|
||||||
|
|
|
@ -16,7 +16,18 @@ defmodule Pleroma.Web.RichMedia.Helpers do
|
||||||
recv_timeout: 2_000
|
recv_timeout: 2_000
|
||||||
]
|
]
|
||||||
|
|
||||||
defp headers, do: [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
|
defp headers do
|
||||||
|
user_agent =
|
||||||
|
case Config.get([:rich_media, :user_agent], :default) do
|
||||||
|
:default ->
|
||||||
|
Pleroma.Application.user_agent() <> "; Bot"
|
||||||
|
|
||||||
|
custom ->
|
||||||
|
custom
|
||||||
|
end
|
||||||
|
|
||||||
|
[{"user-agent", user_agent}]
|
||||||
|
end
|
||||||
|
|
||||||
@spec validate_page_url(URI.t() | binary()) :: :ok | :error
|
@spec validate_page_url(URI.t() | binary()) :: :ok | :error
|
||||||
defp validate_page_url(page_url) when is_binary(page_url) do
|
defp validate_page_url(page_url) when is_binary(page_url) do
|
||||||
|
|
Loading…
Reference in a new issue