aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoreal <eal@waifu.club>2017-12-12 21:04:41 +0200
committereal <eal@waifu.club>2017-12-12 21:04:41 +0200
commitfdfb508259f45154313df0ae343ee6ca26802505 (patch)
treec2d81da69ae513f705937c0f97db9eb717679230 /lib
parentd89193a8d77f67ad5f6ccc7897889c1ef2d030fa (diff)
downloadpleroma-fdfb508259f45154313df0ae343ee6ca26802505.tar.gz
Run follow import in the background.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/twitter_api/controllers/util_controller.ex24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
index 8eeaa0064..9079d2f9b 100644
--- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -1,5 +1,6 @@
defmodule Pleroma.Web.TwitterAPI.UtilController do
use Pleroma.Web, :controller
+ require Logger
alias Pleroma.Web
alias Pleroma.Formatter
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -78,20 +79,19 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
follow_import(conn, %{"list" => File.read!(listfile.path)})
end
def follow_import(%{assigns: %{user: user}} = conn, %{"list" => list}) do
- errors = list
- |> String.split()
+ Task.start_link(fn ->
+ String.split(list)
|> Enum.map(fn nick ->
- with %User{} = follower <- User.get_cached_by_ap_id(user.ap_id),
- %User{} = followed <- User.get_or_fetch_by_nickname(nick),
- {:ok, follower} <- User.follow(follower, followed),
- {:ok, _activity} <- ActivityPub.follow(follower, followed) do
- :ok
- else
- _e -> nick
- end
+ with %User{} = follower <- User.get_cached_by_ap_id(user.ap_id),
+ %User{} = followed <- User.get_or_fetch_by_nickname(nick),
+ {:ok, follower} <- User.follow(follower, followed) do
+ ActivityPub.follow(follower, followed)
+ else
+ _e -> Logger.debug "follow_import: following #{nick} failed"
+ end
+ end)
end)
- |> Enum.reject(fn x -> x == :ok end)
- json conn, %{"failed follows" => errors}
+ json conn, "job started"
end
end