~cytrogen/masto-fe

ref: 86c9c5afa045b9e2cfa41c15db63ad97d58954c1 masto-fe/app/models/account_suggestions.rb -rw-r--r-- 713 bytes
86c9c5af — Claire Merge commit '40ba6e119b7457161fd43b449875d0fb9d473c1a' into glitch-soc/merge-upstream 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

class AccountSuggestions
  SOURCES = [
    AccountSuggestions::SettingSource,
    AccountSuggestions::PastInteractionsSource,
    AccountSuggestions::GlobalSource,
  ].freeze

  def self.get(account, limit)
    SOURCES.each_with_object([]) do |source_class, suggestions|
      source_suggestions = source_class.new.get(
        account,
        skip_account_ids: suggestions.map(&:account_id),
        limit: limit - suggestions.size
      )

      suggestions.concat(source_suggestions)
    end
  end

  def self.remove(account, target_account_id)
    SOURCES.each do |source_class|
      source = source_class.new
      source.remove(account, target_account_id)
    end
  end
end