Transmogrifier: Use Containment.get_actor to get actors.
authorlain <lain@soykaf.club>
Tue, 27 Aug 2019 17:22:30 +0000 (12:22 -0500)
committerlain <lain@soykaf.club>
Tue, 27 Aug 2019 17:22:30 +0000 (12:22 -0500)
lib/pleroma/object.ex
lib/pleroma/web/activity_pub/transmogrifier.ex

index 468549c87b1b2525fd0cdb347adb1378ea003196..c8d339c190ba048bc2248f29dfac1807c634cbd9 100644 (file)
@@ -230,8 +230,4 @@ defmodule Pleroma.Object do
       _ -> :noop
     end
   end
-
-  def get_ap_id(%{"id" => id}), do: id
-  def get_ap_id(id) when is_binary(id), do: id
-  def get_ap_id(_), do: {:error, "Object is not a string and has no id."}
 end
index 6c4259c024710360eecc7a96065f153d971c74b7..468961bd0e204dbe5b294d6272ba26a142d82897 100644 (file)
@@ -464,8 +464,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
         %{"type" => "Follow", "object" => followed, "actor" => follower, "id" => id} = data,
         _options
       ) do
-    with %User{local: true} = followed <- User.get_cached_by_ap_id(Object.get_ap_id(followed)),
-         {:ok, %User{} = follower} <- User.get_or_fetch_by_ap_id(Object.get_ap_id(follower)),
+    with %User{local: true} = followed <-
+           User.get_cached_by_ap_id(Containment.get_actor(%{"actor" => followed})),
+         {:ok, %User{} = follower} <-
+           User.get_or_fetch_by_ap_id(Containment.get_actor(%{"actor" => follower})),
          {:ok, activity} <- ActivityPub.follow(follower, followed, id, false) do
       with deny_follow_blocked <- Pleroma.Config.get([:user, :deny_follow_blocked]),
            {_, false} <- {:user_blocked, User.blocks?(followed, follower) && deny_follow_blocked},