about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-12-19 13:52:54 +0100
committerThibaut Girka <thib@sitedethib.com>2019-12-19 13:52:54 +0100
commitab5ff638f2968e3f434e504c7caab370bf71c9c0 (patch)
tree172f2c2fc8192688b960dd2bd42ea126ad9245fb /app/services
parent66ab1f83b0d342341181e0c88da83c966391fc0c (diff)
parent902c6bed5aab12c2e97af3452f122247777226af (diff)
Merge branch 'master' into glitch-soc/master
Conflicts:
- `config/locales/en.yml`
  No real conflict, upstream added a translatable string “too close” to
  one specific to glitch-soc
- `lib/mastodon/statuses_cli.rb`
  Fixes made upstream, while changed in glitch-soc to keep bookmarked statuses
- `package.json`
  No real conflict, additional dependency in glitch-soc
Diffstat (limited to 'app/services')
-rw-r--r--app/services/backup_service.rb4
-rw-r--r--app/services/bootstrap_timeline_service.rb2
-rw-r--r--app/services/fetch_link_card_service.rb2
-rw-r--r--app/services/fetch_oembed_service.rb2
-rw-r--r--app/services/fetch_remote_account_service.rb17
-rw-r--r--app/services/fetch_remote_status_service.rb9
-rw-r--r--app/services/fetch_resource_service.rb2
-rw-r--r--app/services/resolve_url_service.rb10
8 files changed, 13 insertions, 35 deletions
diff --git a/app/services/backup_service.rb b/app/services/backup_service.rb
index cc9fb1f4e..0b57b6d0c 100644
--- a/app/services/backup_service.rb
+++ b/app/services/backup_service.rb
@@ -3,6 +3,8 @@
 require 'rubygems/package'
 
 class BackupService < BaseService
+  include Payloadable
+
   attr_reader :account, :backup, :collection
 
   def call(backup)
@@ -20,7 +22,7 @@ class BackupService < BaseService
 
     account.statuses.with_includes.reorder(nil).find_in_batches do |statuses|
       statuses.each do |status|
-        item = serialize(status, ActivityPub::ActivitySerializer)
+        item = serialize_payload(status, ActivityPub::ActivitySerializer, signer: @account)
         item.delete(:'@context')
 
         unless item[:type] == 'Announce' || item[:object][:attachment].blank?
diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb
index c489601c1..8412aa7e7 100644
--- a/app/services/bootstrap_timeline_service.rb
+++ b/app/services/bootstrap_timeline_service.rb
@@ -5,7 +5,7 @@ class BootstrapTimelineService < BaseService
     @source_account = source_account
 
     autofollow_inviter!
-    autofollow_bootstrap_timeline_accounts!
+    autofollow_bootstrap_timeline_accounts! if Setting.enable_bootstrap_timeline_accounts
   end
 
   private
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 5d4a7c303..91141c1f5 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -45,7 +45,7 @@ class FetchLinkCardService < BaseService
   def html
     return @html if defined?(@html)
 
-    Request.new(:get, @url).perform do |res|
+    Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res|
       if res.code == 200 && res.mime_type == 'text/html'
         @html = res.body_with_limit
         @html_charset = res.charset
diff --git a/app/services/fetch_oembed_service.rb b/app/services/fetch_oembed_service.rb
index 76d971bc5..67e33875c 100644
--- a/app/services/fetch_oembed_service.rb
+++ b/app/services/fetch_oembed_service.rb
@@ -93,7 +93,7 @@ class FetchOEmbedService
   def html
     return @html if defined?(@html)
 
-    @html = @options[:html] || Request.new(:get, @url).perform do |res|
+    @html = @options[:html] || Request.new(:get, @url).add_headers('Accept' => 'text/html').perform do |res|
       res.code != 200 || res.mime_type != 'text/html' ? nil : res.body_with_limit
     end
   end
diff --git a/app/services/fetch_remote_account_service.rb b/app/services/fetch_remote_account_service.rb
deleted file mode 100644
index 3cd06e30f..000000000
--- a/app/services/fetch_remote_account_service.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class FetchRemoteAccountService < BaseService
-  def call(url, prefetched_body = nil, protocol = :ostatus)
-    if prefetched_body.nil?
-      resource_url, resource_options, protocol = FetchResourceService.new.call(url)
-    else
-      resource_url     = url
-      resource_options = { prefetched_body: prefetched_body }
-    end
-
-    case protocol
-    when :activitypub
-      ActivityPub::FetchRemoteAccountService.new.call(resource_url, **resource_options)
-    end
-  end
-end
diff --git a/app/services/fetch_remote_status_service.rb b/app/services/fetch_remote_status_service.rb
index 208dc7809..eafde4d4a 100644
--- a/app/services/fetch_remote_status_service.rb
+++ b/app/services/fetch_remote_status_service.rb
@@ -1,17 +1,14 @@
 # frozen_string_literal: true
 
 class FetchRemoteStatusService < BaseService
-  def call(url, prefetched_body = nil, protocol = :ostatus)
+  def call(url, prefetched_body = nil)
     if prefetched_body.nil?
-      resource_url, resource_options, protocol = FetchResourceService.new.call(url)
+      resource_url, resource_options = FetchResourceService.new.call(url)
     else
       resource_url     = url
       resource_options = { prefetched_body: prefetched_body }
     end
 
-    case protocol
-    when :activitypub
-      ActivityPub::FetchRemoteStatusService.new.call(resource_url, **resource_options)
-    end
+    ActivityPub::FetchRemoteStatusService.new.call(resource_url, **resource_options) unless resource_url.nil?
   end
 end
diff --git a/app/services/fetch_resource_service.rb b/app/services/fetch_resource_service.rb
index 3676d899d..34382d279 100644
--- a/app/services/fetch_resource_service.rb
+++ b/app/services/fetch_resource_service.rb
@@ -33,7 +33,7 @@ class FetchResourceService < BaseService
       body = response.body_with_limit
       json = body_to_json(body)
 
-      [json['id'], { prefetched_body: body, id: true }, :activitypub] if supported_context?(json) && (equals_or_includes_any?(json['type'], ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES) || expected_type?(json))
+      [json['id'], { prefetched_body: body, id: true }] if supported_context?(json) && (equals_or_includes_any?(json['type'], ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES) || expected_type?(json))
     elsif !terminal
       link_header = response['Link'] && parse_link_header(response)
 
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb
index 4e971a4b8..79b1bad0c 100644
--- a/app/services/resolve_url_service.rb
+++ b/app/services/resolve_url_service.rb
@@ -19,9 +19,9 @@ class ResolveURLService < BaseService
 
   def process_url
     if equals_or_includes_any?(type, ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES)
-      FetchRemoteAccountService.new.call(resource_url, body, protocol)
+      ActivityPub::FetchRemoteAccountService.new.call(resource_url, prefetched_body: body)
     elsif equals_or_includes_any?(type, ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES)
-      status = FetchRemoteStatusService.new.call(resource_url, body, protocol)
+      status = FetchRemoteStatusService.new.call(resource_url, body)
       authorize_with @on_behalf_of, status, :show? unless status.nil?
       status
     elsif fetched_resource.nil? && @on_behalf_of.present?
@@ -45,12 +45,8 @@ class ResolveURLService < BaseService
     fetched_resource.second[:prefetched_body]
   end
 
-  def protocol
-    fetched_resource.third
-  end
-
   def type
-    return json_data['type'] if protocol == :activitypub
+    json_data['type']
   end
 
   def json_data