small refactoring
authorMaksim Pechnikov <parallel588@gmail.com>
Thu, 17 Sep 2020 06:13:43 +0000 (09:13 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Thu, 17 Sep 2020 06:13:43 +0000 (09:13 +0300)
lib/pleroma/user/import.ex
lib/pleroma/workers/background_worker.ex

index de27bdc4c14a710762def4222d63e78971992998..e458021c87b1fdb35a1369238bd96c3c4e002dec 100644 (file)
@@ -65,20 +65,14 @@ defmodule Pleroma.User.Import do
   def blocks_import(%User{} = blocker, [_ | _] = identifiers) do
     BackgroundWorker.enqueue(
       "blocks_import",
-      %{
-        "blocker_id" => blocker.id,
-        "blocked_identifiers" => identifiers
-      }
+      %{"user_id" => blocker.id, "identifiers" => identifiers}
     )
   end
 
   def follow_import(%User{} = follower, [_ | _] = identifiers) do
     BackgroundWorker.enqueue(
       "follow_import",
-      %{
-        "follower_id" => follower.id,
-        "followed_identifiers" => identifiers
-      }
+      %{"user_id" => follower.id, "identifiers" => identifiers}
     )
   end
 
index f9c767ee0c69a8c03bd35c420dc30a29aa153d1d..55b5a13d9e451950a5bbf8560a3b7e0e3371a3fd 100644 (file)
@@ -26,33 +26,10 @@ defmodule Pleroma.Workers.BackgroundWorker do
     User.perform(:force_password_reset, user)
   end
 
-  def perform(%Job{
-        args: %{
-          "op" => "blocks_import",
-          "blocker_id" => blocker_id,
-          "blocked_identifiers" => blocked_identifiers
-        }
-      }) do
-    blocker = User.get_cached_by_id(blocker_id)
-    {:ok, User.Import.perform(:blocks_import, blocker, blocked_identifiers)}
-  end
-
-  def perform(%Job{
-        args: %{
-          "op" => "follow_import",
-          "follower_id" => follower_id,
-          "followed_identifiers" => followed_identifiers
-        }
-      }) do
-    follower = User.get_cached_by_id(follower_id)
-    {:ok, User.Import.perform(:follow_import, follower, followed_identifiers)}
-  end
-
-  def perform(%Job{
-        args: %{"op" => "mutes_import", "user_id" => user_id, "identifiers" => identifiers}
-      }) do
+  def perform(%Job{args: %{"op" => op, "user_id" => user_id, "identifiers" => identifiers}})
+      when op in ["blocks_import", "follow_import", "mutes_import"] do
     user = User.get_cached_by_id(user_id)
-    {:ok, User.Import.perform(:mutes_import, user, identifiers)}
+    {:ok, User.Import.perform(String.to_atom(op), user, identifiers)}
   end
 
   def perform(%Job{args: %{"op" => "media_proxy_preload", "message" => message}}) do