diff --git a/.env.production.sample b/.env.production.sample index 7bcce0f7e59b98..4d058f0119180d 100644 --- a/.env.production.sample +++ b/.env.production.sample @@ -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 diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb index 126c0fa2e59791..8ed2974b09a0c1 100644 --- a/app/services/bootstrap_timeline_service.rb +++ b/app/services/bootstrap_timeline_service.rb @@ -6,6 +6,7 @@ def call(source_account) autofollow_inviter! notify_staff! + autofollow! end private @@ -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')