about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-03-22 19:50:11 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-03-22 19:50:11 +0100
commit5ac380c1226a8225a84835f6c70b7bdf00f99fb2 (patch)
tree432e2dce315060938ecc0ba05a9ae20fdb1da2d7 /app/services
parent02ac94490a67659c7cc669ead5b107b724db6e68 (diff)
parent2626097869c9520c21aaba73c9bcfe72c0f25f28 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/models/status.rb`:
  Upstream added lines close to a glitch-soc only line, not a real conflict.
  Applied upstream's changes (added hooks) while keeping glitch-soc's changes
  (`local_only` scope).
- `config/environments/production.rb`:
  Upstream removed a header, while we have glitch-soc specific ones.
  Removed the header removed upstream.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/import_service.rb12
-rw-r--r--app/services/search_service.rb12
2 files changed, 2 insertions, 22 deletions
diff --git a/app/services/import_service.rb b/app/services/import_service.rb
index 940c236d4..56f191c1f 100644
--- a/app/services/import_service.rb
+++ b/app/services/import_service.rb
@@ -120,7 +120,7 @@ class ImportService < BaseService
     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
diff --git a/app/services/search_service.rb b/app/services/search_service.rb
index 93b72fa0c..b1ce5453f 100644
--- a/app/services/search_service.rb
+++ b/app/services/search_service.rb
@@ -49,7 +49,7 @@ class SearchService < BaseService
     results             = definition.limit(@limit).offset(@offset).objects.compact
     account_ids         = results.map(&:account_id)
     account_domains     = results.map(&:account_domain)
-    preloaded_relations = relations_map_for_account(@account, account_ids, account_domains)
+    preloaded_relations = @account.relations_map(account_ids, account_domains)
 
     results.reject { |status| StatusFilter.new(status, @account, preloaded_relations).filtered? }
   rescue Faraday::ConnectionFailed, Parslet::ParseFailed
@@ -111,16 +111,6 @@ class SearchService < BaseService
     @options[:type].blank? || @options[:type] == 'statuses'
   end
 
-  def relations_map_for_account(account, account_ids, domains)
-    {
-      blocking: Account.blocking_map(account_ids, account.id),
-      blocked_by: Account.blocked_by_map(account_ids, account.id),
-      muting: Account.muting_map(account_ids, account.id),
-      following: Account.following_map(account_ids, account.id),
-      domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, account.id),
-    }
-  end
-
   def parsed_query
     SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query))
   end