Change User-Agent of link preview fetching service to include "Bot" (#14248)

This forces Twitter to render OpenGraph tags in the response
signup-info-prompt
Eugen Rochko 2020-07-07 10:55:18 +02:00 committed by GitHub
parent c7c07abe44
commit ed04697510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -45,7 +45,7 @@ class FetchLinkCardService < BaseService
def html def html
return @html if defined?(@html) return @html if defined?(@html)
Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res| Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => Mastodon::Version.user_agent + ' Bot').perform do |res|
if res.code == 200 && res.mime_type == 'text/html' if res.code == 200 && res.mime_type == 'text/html'
@html = res.body_with_limit @html = res.body_with_limit
@html_charset = res.charset @html_charset = res.charset