mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 21:06:01 +01:00
Add Accept-Language header when fetching preview card (#31232)
This commit is contained in:
parent
06c3a41faf
commit
4853a2bada
1 changed files with 7 additions and 1 deletions
|
@ -45,7 +45,13 @@ class FetchLinkCardService < BaseService
|
||||||
def html
|
def html
|
||||||
return @html if defined?(@html)
|
return @html if defined?(@html)
|
||||||
|
|
||||||
@html = Request.new(:get, @url).add_headers('Accept' => 'text/html', 'User-Agent' => "#{Mastodon::Version.user_agent} Bot").perform do |res|
|
headers = {
|
||||||
|
'Accept' => 'text/html',
|
||||||
|
'Accept-Language' => "#{I18n.default_locale}, *;q=0.5",
|
||||||
|
'User-Agent' => "#{Mastodon::Version.user_agent} Bot",
|
||||||
|
}
|
||||||
|
|
||||||
|
@html = Request.new(:get, @url).add_headers(headers).perform do |res|
|
||||||
next unless res.code == 200 && res.mime_type == 'text/html'
|
next unless res.code == 200 && res.mime_type == 'text/html'
|
||||||
|
|
||||||
# We follow redirects, and ideally we want to save the preview card for
|
# We follow redirects, and ideally we want to save the preview card for
|
||||||
|
|
Loading…
Reference in a new issue