commit: 23ecc681c4e2b817c9694dbd465b5a7847ca38c3
parent: 82bbf57e7a179b3c2856a5724bbb808d0abd4b78
Author: ik-fib <ik11235@users.noreply.github.com>
Date: Tue, 18 Apr 2017 23:04:13 +0900
Add "Mastodon" to user agent (#2073)
Remove non-const version string
Freeze option is unnecessary
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git 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)