Drop unused "inReplyToAtomUri" in objects
This commit is contained in:
parent
09416d8a03
commit
ee0e05f930
|
@ -168,7 +168,6 @@ def fix_in_reply_to(object, options \\ [])
|
||||||
def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
||||||
when not is_nil(in_reply_to) do
|
when not is_nil(in_reply_to) do
|
||||||
in_reply_to_id = prepare_in_reply_to(in_reply_to)
|
in_reply_to_id = prepare_in_reply_to(in_reply_to)
|
||||||
object = Map.put(object, "inReplyToAtomUri", in_reply_to_id)
|
|
||||||
depth = (options[:depth] || 0) + 1
|
depth = (options[:depth] || 0) + 1
|
||||||
|
|
||||||
if Federator.allowed_thread_distance?(depth) do
|
if Federator.allowed_thread_distance?(depth) do
|
||||||
|
@ -176,9 +175,8 @@ def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
||||||
%Activity{} <- Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
|
%Activity{} <- Activity.get_create_by_object_ap_id(replied_object.data["id"]) do
|
||||||
object
|
object
|
||||||
|> Map.put("inReplyTo", replied_object.data["id"])
|
|> Map.put("inReplyTo", replied_object.data["id"])
|
||||||
|> Map.put("inReplyToAtomUri", object["inReplyToAtomUri"] || in_reply_to_id)
|
|
||||||
|> Map.put("context", replied_object.data["context"] || object["conversation"])
|
|> Map.put("context", replied_object.data["context"] || object["conversation"])
|
||||||
|> Map.drop(["conversation"])
|
|> Map.drop(["conversation", "inReplyToAtomUri"])
|
||||||
else
|
else
|
||||||
e ->
|
e ->
|
||||||
Logger.warn("Couldn't fetch #{inspect(in_reply_to_id)}, error: #{inspect(e)}")
|
Logger.warn("Couldn't fetch #{inspect(in_reply_to_id)}, error: #{inspect(e)}")
|
||||||
|
|
|
@ -116,7 +116,8 @@ test "it fetches reply-to activities if we don't have them" do
|
||||||
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||||
)
|
)
|
||||||
|
|
||||||
assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
assert returned_object.data["inReplyTo"] ==
|
||||||
|
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it does not fetch reply-to activities beyond max replies depth limit" do
|
test "it does not fetch reply-to activities beyond max replies depth limit" do
|
||||||
|
@ -140,8 +141,7 @@ test "it does not fetch reply-to activities beyond max replies depth limit" do
|
||||||
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||||
)
|
)
|
||||||
|
|
||||||
assert returned_object.data["inReplyToAtomUri"] ==
|
assert returned_object.data["inReplyTo"] == "https://shitposter.club/notice/2827873"
|
||||||
"https://shitposter.club/notice/2827873"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1072,7 +1072,7 @@ test "returns not modified object when hasn't containts inReplyTo field", %{data
|
||||||
assert Transmogrifier.fix_in_reply_to(data) == data
|
assert Transmogrifier.fix_in_reply_to(data) == data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns object with inReplyToAtomUri when denied incoming reply", %{data: data} do
|
test "returns object with inReplyTo when denied incoming reply", %{data: data} do
|
||||||
Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
|
Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
|
||||||
|
|
||||||
object_with_reply =
|
object_with_reply =
|
||||||
|
@ -1080,26 +1080,22 @@ test "returns object with inReplyToAtomUri when denied incoming reply", %{data:
|
||||||
|
|
||||||
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
||||||
assert modified_object["inReplyTo"] == "https://shitposter.club/notice/2827873"
|
assert modified_object["inReplyTo"] == "https://shitposter.club/notice/2827873"
|
||||||
assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
|
||||||
|
|
||||||
object_with_reply =
|
object_with_reply =
|
||||||
Map.put(data["object"], "inReplyTo", %{"id" => "https://shitposter.club/notice/2827873"})
|
Map.put(data["object"], "inReplyTo", %{"id" => "https://shitposter.club/notice/2827873"})
|
||||||
|
|
||||||
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
||||||
assert modified_object["inReplyTo"] == %{"id" => "https://shitposter.club/notice/2827873"}
|
assert modified_object["inReplyTo"] == %{"id" => "https://shitposter.club/notice/2827873"}
|
||||||
assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
|
||||||
|
|
||||||
object_with_reply =
|
object_with_reply =
|
||||||
Map.put(data["object"], "inReplyTo", ["https://shitposter.club/notice/2827873"])
|
Map.put(data["object"], "inReplyTo", ["https://shitposter.club/notice/2827873"])
|
||||||
|
|
||||||
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
||||||
assert modified_object["inReplyTo"] == ["https://shitposter.club/notice/2827873"]
|
assert modified_object["inReplyTo"] == ["https://shitposter.club/notice/2827873"]
|
||||||
assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
|
||||||
|
|
||||||
object_with_reply = Map.put(data["object"], "inReplyTo", [])
|
object_with_reply = Map.put(data["object"], "inReplyTo", [])
|
||||||
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
modified_object = Transmogrifier.fix_in_reply_to(object_with_reply)
|
||||||
assert modified_object["inReplyTo"] == []
|
assert modified_object["inReplyTo"] == []
|
||||||
assert modified_object["inReplyToAtomUri"] == ""
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
@tag capture_log: true
|
||||||
|
@ -1117,8 +1113,6 @@ test "returns modified object when allowed incoming reply", %{data: data} do
|
||||||
assert modified_object["inReplyTo"] ==
|
assert modified_object["inReplyTo"] ==
|
||||||
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
"tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
|
||||||
|
|
||||||
assert modified_object["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
|
||||||
|
|
||||||
assert modified_object["context"] ==
|
assert modified_object["context"] ==
|
||||||
"tag:shitposter.club,2017-05-05:objectType=thread:nonce=3c16e9c2681f6d26"
|
"tag:shitposter.club,2017-05-05:objectType=thread:nonce=3c16e9c2681f6d26"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue