about summary refs log tree commit diff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-03-23 10:15:13 +0100
committerGitHub <noreply@github.com>2023-03-23 10:15:13 +0100
commit867790e07a149b1213936c3ff1fc5815d37e2e94 (patch)
treed165b5ba19e907a8e57b1abf5ab5cf408419e051 /app/models/concerns
parent02ac94490a67659c7cc669ead5b107b724db6e68 (diff)
parentb4f60bc6de4ece3b2ff908d31a0c34ddbbfacf2c (diff)
Merge pull request #2144 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/account_interactions.rb15
-rw-r--r--app/models/concerns/status_threading_concern.rb14
2 files changed, 16 insertions, 13 deletions
diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb
index 1898516b0..48ab1349d 100644
--- a/app/models/concerns/account_interactions.rb
+++ b/app/models/concerns/account_interactions.rb
@@ -292,6 +292,21 @@ module AccountInteractions
     end
   end
 
+  def relations_map(account_ids, domains = nil, **options)
+    relations = {
+      blocked_by: Account.blocked_by_map(account_ids, id),
+      following: Account.following_map(account_ids, id),
+    }
+
+    return relations if options[:skip_blocking_and_muting]
+
+    relations.merge!({
+      blocking: Account.blocking_map(account_ids, id),
+      muting: Account.muting_map(account_ids, id),
+      domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, id),
+    })
+  end
+
   private
 
   def remove_potential_friendship(other_account)
diff --git a/app/models/concerns/status_threading_concern.rb b/app/models/concerns/status_threading_concern.rb
index 8b628beea..2ca3b66c2 100644
--- a/app/models/concerns/status_threading_concern.rb
+++ b/app/models/concerns/status_threading_concern.rb
@@ -79,7 +79,7 @@ module StatusThreadingConcern
     statuses    = Status.with_accounts(ids).to_a
     account_ids = statuses.map(&:account_id).uniq
     domains     = statuses.filter_map(&:account_domain).uniq
-    relations   = relations_map_for_account(account, account_ids, domains)
+    relations   = account&.relations_map(account_ids, domains) || {}
 
     statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? }
 
@@ -108,16 +108,4 @@ module StatusThreadingConcern
 
     arr
   end
-
-  def relations_map_for_account(account, account_ids, domains)
-    return {} if account.nil?
-
-    {
-      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
 end