commit: db13acf24261a3f3cb1a747a722df1f86a768955
parent: 8939ff39e4b7fba1bc0af0e235979a7a789fa262
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date: Wed, 8 Jul 2020 03:05:20 +0000
Merge branch 'fix/twitter-rich-media-preview' into 'develop'
Add "Bot" to User Agent to coerce Twitter into serving OGP <meta> tags.
Closes #1923
See merge request pleroma/pleroma!2730
Diffstat:
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -76,6 +76,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Resolving Peertube accounts with Webfinger
- `blob:` urls not being allowed by connect-src CSP
- Mastodon API: fix `GET /api/v1/notifications` not returning the full result set
+- Rich Media Previews for Twitter links
## [Unreleased (patch)]
diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex
@@ -86,7 +86,10 @@ defmodule Pleroma.Web.RichMedia.Parser do
end
try do
- {:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url, [], adapter: opts)
+ rich_media_agent = Pleroma.Application.user_agent() <> "; Bot"
+
+ {:ok, %Tesla.Env{body: html}} =
+ Pleroma.HTTP.get(url, [{"user-agent", rich_media_agent}], adapter: opts)
html
|> parse_html()