summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-08-11 22:49:55 +0300
committerAriadne Conill <ariadne@dereferenced.org>2019-08-14 01:50:22 +0000
commit5af3c00072b27e4f23567e0defbc3c021ed11b2b (patch)
tree76862c95bf1e1e0e0f20142eb90d387c7ca88a76
parent60c75d6740e5a5194cac4ae690a7b84cfa104efa (diff)
Do not fetch the reply object in `fix_type` unless the object has the
`name` key and use a depth limit when fetching it
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index 65c1f9d9f..af756c21e 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -324,17 +324,24 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
def fix_content_map(object), do: object
- def fix_type(%{"inReplyTo" => reply_id} = object) when is_binary(reply_id) do
- reply = Object.normalize(reply_id)
+ def fix_type(object, options \\ [])
- if reply && (reply.data["type"] == "Question" and object["name"]) do
+ def fix_type(%{"inReplyTo" => reply_id, "name" => _} = object, options)
+ when is_binary(reply_id) do
+ reply =
+ with true <- Federator.allowed_incoming_reply_depth?(options[:depth]),
+ {:ok, object} <- get_obj_helper(reply_id) do
+ object
+ end
+
+ if reply && reply.data["type"] == "Question" do
Map.put(object, "type", "Answer")
else
object
end
end
- def fix_type(object), do: object
+ def fix_type(object, _), do: object
defp mastodon_follow_hack(%{"id" => id, "actor" => follower_id}, followed) do
with true <- id =~ "follows",