user: migrate follow/blocks import to job queue

This commit is contained in:
William Pitcock 2019-05-13 02:09:28 +00:00
commit 69a9e0563c
2 changed files with 50 additions and 37 deletions

View file

@ -310,7 +310,12 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
String.split(line, ",") |> List.first()
end)
|> List.delete("Account address"),
{:ok, _} = Task.start(fn -> User.follow_import(follower, followed_identifiers) end) do
:ok <-
PleromaJobQueue.enqueue(:background, User, [
:follow_import,
follower,
followed_identifiers
]) do
json(conn, "job started")
end
end
@ -321,7 +326,12 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
def blocks_import(%{assigns: %{user: blocker}} = conn, %{"list" => list}) do
with blocked_identifiers <- String.split(list),
{:ok, _} = Task.start(fn -> User.blocks_import(blocker, blocked_identifiers) end) do
:ok <-
PleromaJobQueue.enqueue(:background, User, [
:blocks_import,
blocker,
blocked_identifiers
]) do
json(conn, "job started")
end
end