mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-30 06:19:03 +01:00
9f5deb310b
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
34 lines
704 B
Ruby
34 lines
704 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AccountSuggestions::Source
|
|
def key
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def get(_account, **kwargs)
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def remove(_account, target_account_id)
|
|
raise NotImplementedError
|
|
end
|
|
|
|
protected
|
|
|
|
def as_ordered_suggestions(scope, ordered_list)
|
|
return [] if ordered_list.empty?
|
|
|
|
map = scope.index_by { |account| to_ordered_list_key(account) }
|
|
|
|
ordered_list.filter_map { |ordered_list_key| map[ordered_list_key] }.map do |account|
|
|
AccountSuggestions::Suggestion.new(
|
|
account: account,
|
|
source: key
|
|
)
|
|
end
|
|
end
|
|
|
|
def to_ordered_list_key(_account)
|
|
raise NotImplementedError
|
|
end
|
|
end
|