about summary refs log tree commit diff
path: root/app/workers/maintenance
diff options
context:
space:
mode:
authorJenkins <jenkins@jenkins.ninjawedding.org>2018-05-31 01:17:25 +0000
committerJenkins <jenkins@jenkins.ninjawedding.org>2018-05-31 01:17:25 +0000
commit165b5dc7f5711efd07adb73316e94d89b9e7e3a3 (patch)
treeeafd267dd5b167961455e24bbdba89b025563177 /app/workers/maintenance
parente7b3a4263e5a22a64b7fdc3a965fa38e1935157a (diff)
parentc61c4565ab17f7e882b93f96e4d97ff1681a7bcf (diff)
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'app/workers/maintenance')
-rw-r--r--app/workers/maintenance/destroy_media_worker.rb14
-rw-r--r--app/workers/maintenance/redownload_account_media_worker.rb16
-rw-r--r--app/workers/maintenance/uncache_media_worker.rb18
3 files changed, 48 insertions, 0 deletions
diff --git a/app/workers/maintenance/destroy_media_worker.rb b/app/workers/maintenance/destroy_media_worker.rb
new file mode 100644
index 000000000..5f052983b
--- /dev/null
+++ b/app/workers/maintenance/destroy_media_worker.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class Maintenance::DestroyMediaWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'pull'
+
+  def perform(media_attachment_id)
+    media = MediaAttachment.find(media_attachment_id)
+    media.destroy
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end
diff --git a/app/workers/maintenance/redownload_account_media_worker.rb b/app/workers/maintenance/redownload_account_media_worker.rb
new file mode 100644
index 000000000..fc26815f2
--- /dev/null
+++ b/app/workers/maintenance/redownload_account_media_worker.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class Maintenance::RedownloadAccountMediaWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'pull', retry: false
+
+  def perform(account_id)
+    account = Account.find(account_id)
+    account.reset_avatar!
+    account.reset_header!
+    account.save
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end
diff --git a/app/workers/maintenance/uncache_media_worker.rb b/app/workers/maintenance/uncache_media_worker.rb
new file mode 100644
index 000000000..f6a51a1b8
--- /dev/null
+++ b/app/workers/maintenance/uncache_media_worker.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class Maintenance::UncacheMediaWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'pull'
+
+  def perform(media_attachment_id)
+    media = MediaAttachment.find(media_attachment_id)
+
+    return unless media.file.exists?
+
+    media.file.destroy
+    media.save
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end