]> cat aescling's git repositories - mastodon.git/commitdiff
Add "Mastodon" to user agent (#2073)
authorik-fib <ik11235@users.noreply.github.com>
Tue, 18 Apr 2017 14:04:13 +0000 (23:04 +0900)
committerEugen <eugen@zeonfederated.com>
Tue, 18 Apr 2017 14:04:13 +0000 (16:04 +0200)
Remove non-const version string

Freeze option is unnecessary

app/services/fetch_link_card_service.rb

index 1b94dfe0cd4ff324850786a0815bd46213004af0..5ab781bfc3740627a3972374f201cbe77ff56e65 100644 (file)
@@ -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)