From 3bb237800983fe6c58520fd272530e2a6bef0709 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Tue, 17 Sep 2019 21:25:29 -0500 Subject: add `FetchAvatarWorker` to (re-)fetch account avatars/headers --- app/workers/fetch_avatar_worker.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/workers/fetch_avatar_worker.rb (limited to 'app') diff --git a/app/workers/fetch_avatar_worker.rb b/app/workers/fetch_avatar_worker.rb new file mode 100644 index 000000000..01a7078dc --- /dev/null +++ b/app/workers/fetch_avatar_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class FetchAvatarMediaWorker + 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 -- cgit