Skip to content

Commit

Permalink
Add Accept-Language header when fetching preview card (mastodon#31232)
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 authored Aug 1, 2024
1 parent 06c3a41 commit 4853a2b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/services/fetch_link_card_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ def process_url
def 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'

# We follow redirects, and ideally we want to save the preview card for
Expand Down

0 comments on commit 4853a2b

Please sign in to comment.