Skip to content

Commit

Permalink
[feature] autofollow accounts set in .env file
Browse files Browse the repository at this point in the history
still need to test.
  • Loading branch information
sneakers-the-rat committed Dec 22, 2022
1 parent 7929b4d commit b7be0d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.production.sample
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ MAX_POLL_OPTION_CHARS=100
# HCAPTCHA_SECRET_KEY=
# HCAPTCHA_SITE_KEY=

# New registrations will automatically follow these accounts (separated by commas)
AUTOFOLLOW=

# IP and session retention
# -----------------------
# Make sure to modify the scheduling of ip_cleanup_scheduler in config/sidekiq.yml
Expand Down
14 changes: 14 additions & 0 deletions app/services/bootstrap_timeline_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def call(source_account)

autofollow_inviter!
notify_staff!
autofollow!
end

private
Expand All @@ -16,6 +17,19 @@ def autofollow_inviter!
FollowService.new.call(@source_account, @source_account.user.invite.user.account)
end

def autofollow!
return unless ENV['AUTOFOLLOW'].present?

ENV['AUTOFOLLOW'].to_s.split(',').each do |account|
begin
to_follow = Account.find_local!(account.strip)
FollowService.new.call(@source_account, to_follow)
rescue ActiveRecord::RecordNotFound
Rails.logger.warn("Could not find account #{account} to autofollow")
end
end
end

def notify_staff!
User.those_who_can(:manage_users).includes(:account).find_each do |user|
LocalNotificationWorker.perform_async(user.account_id, @source_account.id, 'Account', 'admin.sign_up')
Expand Down

0 comments on commit b7be0d3

Please sign in to comment.