side_effects: Don’t increase_replies_count when it’s an Answer
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 2 Nov 2020 04:43:06 +0000 (05:43 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 2 Nov 2020 04:56:17 +0000 (05:56 +0100)
lib/pleroma/web/activity_pub/side_effects.ex
test/pleroma/web/activity_pub/transmogrifier/answer_handling_test.exs

index 0fff5faf2d4a138978f6ff8c85097574e7f0320d..9b1171d07f7286bbf02eeb00572ee8e7380873eb 100644 (file)
@@ -187,7 +187,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
       {:ok, notifications} = Notification.create_notifications(activity, do_send: false)
       {:ok, _user} = ActivityPub.increase_note_count_if_public(user, object)
 
-      if in_reply_to = object.data["inReplyTo"] do
+      if in_reply_to = object.data["inReplyTo"] && object.data["type"] != "Answer" do
         Object.increase_replies_count(in_reply_to)
       end
 
index 0f6605c3f2e274a79ec3d629ab4d61210667dd45..e7d85a2c589f3743a1972cbf557d728909091d41 100644 (file)
@@ -27,6 +27,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
       })
 
     object = Object.normalize(activity)
+    assert object.data["repliesCount"] == nil
 
     data =
       File.read!("test/fixtures/mastodon-vote.json")
@@ -41,7 +42,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
     assert answer_object.data["inReplyTo"] == object.data["id"]
 
     new_object = Object.get_by_ap_id(object.data["id"])
-    assert new_object.data["replies_count"] == object.data["replies_count"]
+    assert new_object.data["repliesCount"] == nil
 
     assert Enum.any?(
              new_object.data["oneOf"],