activitypub: use Object.normalize() instead of Object.get_by_ap_id() directly.
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 18 Jun 2018 21:01:33 +0000 (21:01 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Wed, 27 Jun 2018 13:07:29 +0000 (13:07 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/transmogrifier.ex

index 195679fad9ebe9374e3a8a1fa6d6e0c1cda5d31a..93219d76ab6e0cce29f93cefd2c25ebfcc658a15 100644 (file)
@@ -670,7 +670,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
                recv_timeout: 20000
              ),
            {:ok, data} <- Jason.decode(body),
-           nil <- Object.get_by_ap_id(data["id"]),
+           nil <- Object.normalize(data),
            params <- %{
              "type" => "Create",
              "to" => data["to"],
@@ -679,7 +679,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
              "object" => data
            },
            {:ok, activity} <- Transmogrifier.handle_incoming(params) do
-        {:ok, Object.get_by_ap_id(activity.data["object"]["id"])}
+        {:ok, Object.normalize(activity.data["object"])}
       else
         object = %Object{} ->
           {:ok, object}
@@ -688,7 +688,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
           Logger.info("Couldn't get object via AP, trying out OStatus fetching...")
 
           case OStatus.fetch_activity_from_url(id) do
-            {:ok, [activity | _]} -> {:ok, Object.get_by_ap_id(activity.data["object"]["id"])}
+            {:ok, [activity | _]} -> {:ok, Object.normalize(activity.data["object"])}
             e -> e
           end
       end
index 30cd70fb656096df97ee86fe285d8fbe3a174dc3..8b5c85f423746f59b7d39c3dd3ba32314b5f9a99 100644 (file)
@@ -412,7 +412,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   def handle_incoming(_), do: :error
 
   def get_obj_helper(id) do
-    if object = Object.get_by_ap_id(id), do: {:ok, object}, else: nil
+    if object = Object.normalize(id), do: {:ok, object}, else: nil
   end
 
   def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) do