forked from AkkomaGang/akkoma
fixed a visibility of functions
This commit is contained in:
parent
579763126f
commit
b023110799
1 changed files with 15 additions and 16 deletions
|
@ -18,22 +18,11 @@ def perform(
|
||||||
},
|
},
|
||||||
_job
|
_job
|
||||||
) do
|
) do
|
||||||
hrefs =
|
attachments
|
||||||
Enum.flat_map(attachments, fn attachment ->
|
|> Enum.flat_map(fn item -> Enum.map(item["url"], & &1["href"]) end)
|
||||||
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
|
|> fetch_objects
|
||||||
|> prepare_objects(actor, Enum.map(attachments, & &1["name"]))
|
|> prepare_objects(actor, Enum.map(attachments, & &1["name"]))
|
||||||
|> Enum.reduce({[], []}, fn {href, %{id: id, count: count}}, {ids, hrefs} ->
|
|> filter_objects
|
||||||
with 1 <- count do
|
|
||||||
{ids ++ [id], hrefs ++ [href]}
|
|
||||||
else
|
|
||||||
_ -> {ids ++ [id], hrefs}
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|> do_clean
|
|> do_clean
|
||||||
|
|
||||||
{:ok, :success}
|
{:ok, :success}
|
||||||
|
@ -73,7 +62,17 @@ defp delete_objects(_), do: :ok
|
||||||
|
|
||||||
# we should delete 1 object for any given attachment, but don't delete
|
# we should delete 1 object for any given attachment, but don't delete
|
||||||
# files if there are more than 1 object for it
|
# 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
|
objects
|
||||||
|> Enum.reduce(%{}, fn %{
|
|> Enum.reduce(%{}, fn %{
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -98,7 +97,7 @@ def prepare_objects(objects, actor, names) do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_objects(hrefs) do
|
defp fetch_objects(hrefs) do
|
||||||
from(o in Object,
|
from(o in Object,
|
||||||
where:
|
where:
|
||||||
fragment(
|
fragment(
|
||||||
|
|
Loading…
Reference in a new issue