- },
- _job
- ) do
- hrefs =
- Enum.flat_map(attachments, fn attachment ->
- Enum.map(attachment["url"], & &1["href"])
- end)
-
- # find all objects for copies of the attachments, name and actor doesn't matter here
- hrefs
- |> fetch_objects
- |> prepare_objects(actor, Enum.map(attachments, & &1["name"]))
- |> Enum.reduce({[], []}, fn {href, %{id: id, count: count}}, {ids, hrefs} ->
- with 1 <- count do
- {ids ++ [id], hrefs ++ [href]}
- else
- _ -> {ids ++ [id], hrefs}
- end
- end)
- |> do_clean
+ }
+ }) 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