clean up follow/block imports a little

This commit is contained in:
William Pitcock 2019-05-14 15:07:38 +00:00
parent 69a9e0563c
commit ac3a3abf6b
2 changed files with 30 additions and 14 deletions

View File

@ -1085,6 +1085,22 @@ def perform(:follow_import, %User{} = follower, followed_identifiers)
) )
end end
def blocks_import(%User{} = blocker, blocked_identifiers) when is_list(blocked_identifiers),
do:
PleromaJobQueue.enqueue(:background, __MODULE__, [
:blocks_import,
blocker,
blocked_identifiers
])
def follow_import(%User{} = follower, followed_identifiers) when is_list(followed_identifiers),
do:
PleromaJobQueue.enqueue(:background, __MODULE__, [
:follow_import,
follower,
followed_identifiers
])
def delete_user_activities(%User{ap_id: ap_id} = user) do def delete_user_activities(%User{ap_id: ap_id} = user) do
stream = stream =
ap_id ap_id

View File

@ -309,13 +309,13 @@ def follow_import(%{assigns: %{user: follower}} = conn, %{"list" => list}) do
Enum.map(lines, fn line -> Enum.map(lines, fn line ->
String.split(line, ",") |> List.first() String.split(line, ",") |> List.first()
end) end)
|> List.delete("Account address"), |> List.delete("Account address") do
:ok <- PleromaJobQueue.enqueue(:background, User, [
PleromaJobQueue.enqueue(:background, User, [ :follow_import,
:follow_import, follower,
follower, followed_identifiers
followed_identifiers ])
]) do
json(conn, "job started") json(conn, "job started")
end end
end end
@ -325,13 +325,13 @@ def blocks_import(conn, %{"list" => %Plug.Upload{} = listfile}) do
end end
def blocks_import(%{assigns: %{user: blocker}} = conn, %{"list" => list}) do def blocks_import(%{assigns: %{user: blocker}} = conn, %{"list" => list}) do
with blocked_identifiers <- String.split(list), with blocked_identifiers <- String.split(list) do
:ok <- PleromaJobQueue.enqueue(:background, User, [
PleromaJobQueue.enqueue(:background, User, [ :blocks_import,
:blocks_import, blocker,
blocker, blocked_identifiers
blocked_identifiers ])
]) do
json(conn, "job started") json(conn, "job started")
end end
end end