about summary refs log tree commit diff
path: root/app/workers/fetch_avatar_worker.rb
blob: c5d05492ed1b25878cee9be41350e721cac0da0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

class FetchAvatarWorker
  include Sidekiq::Worker

  sidekiq_options queue: 'bulk', retry: 2

  def perform(account_id)
    account = Account.find(account_id)
    return if account.suspended_at?
    account.reset_avatar! unless account.avatar_remote_url.nil?
    account.reset_header! unless account.header_remote_url.nil?
  rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
    true
  end
end