mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-27 19:41:37 +01:00
edf09ec747
* Add `/api/v1/accounts/familiar_followers` to REST API * Change hide network preference to be stored consistently for local and remote accounts * Add dummy classes to migration * Apply suggestions from code review Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
17 lines
745 B
Ruby
17 lines
745 B
Ruby
# frozen_string_literal: true
|
|
|
|
class FamiliarFollowersPresenter
|
|
class Result < ActiveModelSerializers::Model
|
|
attributes :id, :accounts
|
|
end
|
|
|
|
def initialize(accounts, current_account_id)
|
|
@accounts = accounts
|
|
@current_account_id = current_account_id
|
|
end
|
|
|
|
def accounts
|
|
map = Follow.includes(account: :account_stat).where(target_account_id: @accounts.map(&:id)).where(account_id: Follow.where(account_id: @current_account_id).joins(:target_account).merge(Account.where(hide_collections: [nil, false])).select(:target_account_id)).group_by(&:target_account_id)
|
|
@accounts.map { |account| Result.new(id: account.id, accounts: (account.hide_collections? ? [] : (map[account.id] || [])).map(&:account)) }
|
|
end
|
|
end
|