clean up follow/block imports a little
authorWilliam Pitcock <nenolod@dereferenced.org>
Tue, 14 May 2019 15:07:38 +0000 (15:07 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 14 May 2019 15:07:38 +0000 (15:07 +0000)
lib/pleroma/user.ex
lib/pleroma/web/twitter_api/controllers/util_controller.ex

index c94660de47ad1abb9899587887649ff00fbde600..417d57d727c5b8025bd9afa12f6b9c87c56bfe00 100644 (file)
@@ -1085,6 +1085,22 @@ defmodule Pleroma.User do
     )
   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
     stream =
       ap_id
index 143960206e5189f435836c4602dfbb39f839513e..deaacd946943a0229b633581a9bc51e1aa5516b2 100644 (file)
@@ -309,13 +309,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
            Enum.map(lines, fn line ->
              String.split(line, ",") |> List.first()
            end)
-           |> List.delete("Account address"),
-         :ok <-
-           PleromaJobQueue.enqueue(:background, User, [
-             :follow_import,
-             follower,
-             followed_identifiers
-           ]) do
+           |> List.delete("Account address") do
+      PleromaJobQueue.enqueue(:background, User, [
+        :follow_import,
+        follower,
+        followed_identifiers
+      ])
+
       json(conn, "job started")
     end
   end
@@ -325,13 +325,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
   end
 
   def blocks_import(%{assigns: %{user: blocker}} = conn, %{"list" => list}) do
-    with blocked_identifiers <- String.split(list),
-         :ok <-
-           PleromaJobQueue.enqueue(:background, User, [
-             :blocks_import,
-             blocker,
-             blocked_identifiers
-           ]) do
+    with blocked_identifiers <- String.split(list) do
+      PleromaJobQueue.enqueue(:background, User, [
+        :blocks_import,
+        blocker,
+        blocked_identifiers
+      ])
+
       json(conn, "job started")
     end
   end