Skip to content
Snippets Groups Projects
Commit 23ecc681 authored by ik-fib's avatar ik-fib Committed by Eugen
Browse files

Add "Mastodon" to user agent (#2073)

Remove non-const version string

Freeze option is unnecessary
parent 82bbf57e
No related branches found
No related tags found
No related merge requests found
# 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment