Make attachment cleanup jobs a noop if the setting is disabled.
authorMark Felder <feld@feld.me>
Thu, 28 Jan 2021 20:42:20 +0000 (14:42 -0600)
committerMark Felder <feld@feld.me>
Thu, 28 Jan 2021 20:42:20 +0000 (14:42 -0600)
lib/pleroma/workers/attachments_cleanup_worker.ex

index a2373ebb9f44fe095833e73a4f1701d69183ea62..f5090dae737b2131d8318ce23e0a58718fe13704 100644 (file)
@@ -17,12 +17,14 @@ defmodule Pleroma.Workers.AttachmentsCleanupWorker do
           "object" => %{"data" => %{"attachment" => [_ | _] = attachments, "actor" => actor}}
         }
       }) do
-    attachments
-    |> Enum.flat_map(fn item -> Enum.map(item["url"], & &1["href"]) end)
-    |> fetch_objects
-    |> prepare_objects(actor, Enum.map(attachments, & &1["name"]))
-    |> filter_objects
-    |> do_clean
+    if Pleroma.Config.get([:instance, :cleanup_attachments], false) do
+      attachments
+      |> Enum.flat_map(fn item -> Enum.map(item["url"], & &1["href"]) end)
+      |> fetch_objects
+      |> prepare_objects(actor, Enum.map(attachments, & &1["name"]))
+      |> filter_objects
+      |> do_clean
+    end
 
     {:ok, :success}
   end