gab-social/app/services/bootstrap_timeline_service.rb
mgabdev 88638cc262 Removed autofollow_inviter in BootstrapTimelineService
• Removed:
- autofollow_inviter in BootstrapTimelineService
2020-12-23 00:42:36 -05:00

41 lines
1.1 KiB
Ruby

# frozen_string_literal: true
class BootstrapTimelineService < BaseService
def call(source_account)
@source_account = source_account
autofollow_bootstrap_timeline_accounts!
end
private
def autofollow_bootstrap_timeline_accounts!
bootstrap_timeline_accounts.each do |target_account|
FollowService.new.call(@source_account, target_account)
end
end
def bootstrap_timeline_accounts
return @bootstrap_timeline_accounts if defined?(@bootstrap_timeline_accounts)
@bootstrap_timeline_accounts = bootstrap_timeline_accounts_usernames.empty? ? admin_accounts : local_unlocked_accounts(bootstrap_timeline_accounts_usernames)
end
def bootstrap_timeline_accounts_usernames
@bootstrap_timeline_accounts_usernames ||= (Setting.bootstrap_timeline_accounts || '').split(',').map { |str| str.strip.gsub(/\A@/, '') }.reject(&:blank?)
end
def admin_accounts
User.admins
.includes(:account)
.where(accounts: { locked: false })
.map(&:account)
end
def local_unlocked_accounts(usernames)
Account.local
.where(username: usernames)
.where(locked: false)
end
end