Transmogrifier: On incoming follow accept, update follow counts.
authorlain <lain@soykaf.club>
Tue, 12 May 2020 10:29:37 +0000 (12:29 +0200)
committerrinpatch <rinpatch@sdf.org>
Tue, 12 May 2020 20:05:57 +0000 (23:05 +0300)
lib/pleroma/web/activity_pub/transmogrifier.ex
test/web/activity_pub/transmogrifier_test.exs

index 831739c5f9e98d18c7d135e427904bdbfdd5f96f..3fc4762d6c7a2eac5ad7505bae6efe2197320875 100644 (file)
@@ -544,6 +544,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
          {:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
          %User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
          {:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept) do
+      User.update_follower_count(followed)
+      User.update_following_count(follower)
+
       ActivityPub.accept(%{
         to: follow_activity.data["to"],
         type: "Accept",
@@ -553,7 +556,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
         activity_id: id
       })
     else
-      _e -> :error
+      _e ->
+        :error
     end
   end
 
index 2a3fd92b4752dafd25821bd249acab702606539b..601e5f966cc21cc3a5566e5e26811da2fb2f0fe6 100644 (file)
@@ -1120,6 +1120,12 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       follower = User.get_cached_by_id(follower.id)
 
       assert User.following?(follower, followed) == true
+
+      follower = User.get_by_id(follower.id)
+      assert follower.following_count == 1
+
+      followed = User.get_by_id(followed.id)
+      assert followed.follower_count == 1
     end
 
     test "it fails for incoming accepts which cannot be correlated" do