about summary refs log tree commit diff
path: root/app/services/import_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/import_service.rb')
-rw-r--r--app/services/import_service.rb16
1 files changed, 3 insertions, 13 deletions
diff --git a/app/services/import_service.rb b/app/services/import_service.rb
index 2f48abc36..56f191c1f 100644
--- a/app/services/import_service.rb
+++ b/app/services/import_service.rb
@@ -67,7 +67,7 @@ class ImportService < BaseService
 
   def import_relationships!(action, undo_action, overwrite_scope, limit, extra_fields = {})
     local_domain_suffix = "@#{Rails.configuration.x.local_domain}"
-    items = @data.take(limit).map { |row| [row['Account address']&.strip&.delete_suffix(local_domain_suffix), Hash[extra_fields.map { |key, field_settings| [key, row[field_settings[:header]]&.strip || field_settings[:default]] }]] }.reject { |(id, _)| id.blank? }
+    items = @data.take(limit).map { |row| [row['Account address']&.strip&.delete_suffix(local_domain_suffix), extra_fields.to_h { |key, field_settings| [key, row[field_settings[:header]]&.strip || field_settings[:default]] }] }.reject { |(id, _)| id.blank? }
 
     if @import.overwrite?
       presence_hash = items.each_with_object({}) { |(id, extra), mapping| mapping[id] = [true, extra] }
@@ -114,13 +114,13 @@ class ImportService < BaseService
       status || ActivityPub::FetchRemoteStatusService.new.call(uri)
     rescue HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::UnexpectedResponseError
       nil
-    rescue StandardError => e
+    rescue => e
       Rails.logger.warn "Unexpected error when importing bookmark: #{e}"
       nil
     end
 
     account_ids         = statuses.map(&:account_id)
-    preloaded_relations = relations_map_for_account(@account, account_ids)
+    preloaded_relations = @account.relations_map(account_ids, skip_blocking_and_muting: true)
 
     statuses.keep_if { |status| StatusPolicy.new(@account, status, preloaded_relations).show? }
 
@@ -138,14 +138,4 @@ class ImportService < BaseService
   def import_data
     Paperclip.io_adapters.for(@import.data).read.force_encoding(Encoding::UTF_8)
   end
-
-  def relations_map_for_account(account, account_ids)
-    {
-      blocking: {},
-      blocked_by: Account.blocked_by_map(account_ids, account.id),
-      muting: {},
-      following: Account.following_map(account_ids, account.id),
-      domain_blocking_by_domain: {},
-    }
-  end
 end