aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaksim Pechnikov <parallel588@gmail.com>2020-06-15 20:47:02 +0300
committerMaksim Pechnikov <parallel588@gmail.com>2020-06-15 20:48:22 +0300
commitb02311079961c5193af1c144516a3caeee72b582 (patch)
treea2fd1d96bbf11ed359010dddb88c6b4389e84b9f /lib
parent579763126f52b21733e84594f36b86e270b3005d (diff)
downloadpleroma-b02311079961c5193af1c144516a3caeee72b582.tar.gz
fixed a visibility of functions
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/workers/attachments_cleanup_worker.ex31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/pleroma/workers/attachments_cleanup_worker.ex b/lib/pleroma/workers/attachments_cleanup_worker.ex
index 4ad19c0fc..8deeabda0 100644
--- a/lib/pleroma/workers/attachments_cleanup_worker.ex
+++ b/lib/pleroma/workers/attachments_cleanup_worker.ex
@@ -18,22 +18,11 @@ defmodule Pleroma.Workers.AttachmentsCleanupWorker do
},
_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
+ attachments
+ |> Enum.flat_map(fn item -> Enum.map(item["url"], & &1["href"]) end)
|> 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)
+ |> filter_objects
|> do_clean
{:ok, :success}
@@ -73,7 +62,17 @@ defmodule Pleroma.Workers.AttachmentsCleanupWorker do
# we should delete 1 object for any given attachment, but don't delete
# files if there are more than 1 object for it
- def prepare_objects(objects, actor, names) do
+ defp filter_objects(objects) do
+ Enum.reduce(objects, {[], []}, fn {href, %{id: id, count: count}}, {ids, hrefs} ->
+ with 1 <- count do
+ {ids ++ [id], hrefs ++ [href]}
+ else
+ _ -> {ids ++ [id], hrefs}
+ end
+ end)
+ end
+
+ defp prepare_objects(objects, actor, names) do
objects
|> Enum.reduce(%{}, fn %{
id: id,
@@ -98,7 +97,7 @@ defmodule Pleroma.Workers.AttachmentsCleanupWorker do
end)
end
- def fetch_objects(hrefs) do
+ defp fetch_objects(hrefs) do
from(o in Object,
where:
fragment(