Refactor check_actor_is_active
authorMaxim Filippov <colixer@gmail.com>
Mon, 19 Aug 2019 17:36:25 +0000 (20:36 +0300)
committerMaxim Filippov <colixer@gmail.com>
Mon, 19 Aug 2019 17:36:25 +0000 (20:36 +0300)
lib/pleroma/web/activity_pub/activity_pub.ex

index 16e0c38800c4c9243f28b010e904dd199f5520f7..2e8cbe13d1e4d09eda5e3b56c8c8dd96e9e1ec9e 100644 (file)
@@ -61,18 +61,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     {recipients, to, cc}
   end
 
-  defp check_actor_is_active(true, _), do: :ok
-
-  defp check_actor_is_active(false, actor) do
+  defp check_actor_is_active(actor) do
     if not is_nil(actor) do
       with user <- User.get_cached_by_ap_id(actor),
            false <- user.info.deactivated do
-        :ok
+        true
       else
-        _e -> :reject
+        _e -> false
       end
     else
-      :ok
+      true
     end
   end
 
@@ -124,7 +122,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
     with nil <- Activity.normalize(map),
          map <- lazy_put_activity_defaults(map, fake),
-         :ok <- check_actor_is_active(bypass_actor_check, map["actor"]),
+         true <- bypass_actor_check || check_actor_is_active(map["actor"]),
          {_, true} <- {:remote_limit_error, check_remote_limit(map)},
          {:ok, map} <- MRF.filter(map),
          {recipients, _, _} = get_recipients(map),