about summary refs log tree commit diff
path: root/app/services/fetch_link_card_service.rb
diff options
context:
space:
mode:
authorik-fib <ik11235@users.noreply.github.com>2017-04-18 23:04:13 +0900
committerEugen <eugen@zeonfederated.com>2017-04-18 16:04:13 +0200
commit23ecc681c4e2b817c9694dbd465b5a7847ca38c3 (patch)
treeccd23e2f1a347f6c9c4a4ff9ba7f62fc1dd8d43f /app/services/fetch_link_card_service.rb
parent82bbf57e7a179b3c2856a5724bbb808d0abd4b78 (diff)
Add "Mastodon" to user agent (#2073)
Remove non-const version string

Freeze option is unnecessary
Diffstat (limited to 'app/services/fetch_link_card_service.rb')
-rw-r--r--app/services/fetch_link_card_service.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 1b94dfe0c..5ab781bfc 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -1,6 +1,8 @@
 # frozen_string_literal: true
 
 class FetchLinkCardService < BaseService
+  USER_AGENT = "#{HTTP::Request::USER_AGENT} (Mastodon; +http://#{Rails.configuration.x.local_domain}/)"
+
   def call(status)
     # Get first http/https URL that isn't local
     url = URI.extract(status.text).reject { |uri| (uri =~ /\Ahttps?:\/\//).nil? || TagManager.instance.local_url?(uri) }.first
@@ -26,7 +28,7 @@ class FetchLinkCardService < BaseService
   private
 
   def http_client
-    HTTP.timeout(:per_operation, write: 10, connect: 10, read: 10).follow
+    HTTP.headers(user_agent: USER_AGENT).timeout(:per_operation, write: 10, connect: 10, read: 10).follow
   end
 
   def meta_property(html, property)