Do not fetch the reply object in `fix_type` unless the object has the
authorrinpatch <rinpatch@sdf.org>
Sun, 11 Aug 2019 19:49:55 +0000 (22:49 +0300)
committerrinpatch <rinpatch@sdf.org>
Sun, 11 Aug 2019 19:49:55 +0000 (22:49 +0300)
`name` key and use a depth limit when fetching it

lib/pleroma/web/activity_pub/transmogrifier.ex

index b7bc48f0a9670c498584901cc6f112bd6d5f01d8..0aee9369fb15325384c34b8992b4105787d0c617 100644 (file)
@@ -333,13 +333,15 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
 
   def fix_type(object, options \\ [])
 
-  def fix_type(%{"inReplyTo" => reply_id} = object, options) when is_binary(reply_id) do
+  def fix_type(%{"inReplyTo" => reply_id, "name" => _} = object, options)
+      when is_binary(reply_id) do
     reply =
-      if Federator.allowed_incoming_reply_depth?(options[:depth]) do
-        Object.normalize(reply_id, true)
+      with true <- Federator.allowed_incoming_reply_depth?(options[:depth]),
+           {:ok, object} <- get_obj_helper(reply_id, options) do
+        object
       end
 
-    if reply && (reply.data["type"] == "Question" and object["name"]) do
+    if reply && reply.data["type"] == "Question" do
       Map.put(object, "type", "Answer")
     else
       object