Make attachment cleanup jobs a noop if the setting is disabled.

This commit is contained in:
Mark Felder 2021-01-28 14:42:20 -06:00
parent 7f07871639
commit 13d79c281f
1 changed files with 8 additions and 6 deletions

View File

@ -17,12 +17,14 @@ def perform(%Job{
"object" => %{"data" => %{"attachment" => [_ | _] = attachments, "actor" => actor}}
}
}) do
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