Transmogrifier: On incoming follow accept, update follow counts.
authorlain <lain@soykaf.club>
Tue, 12 May 2020 10:29:37 +0000 (12:29 +0200)
committerlain <lain@soykaf.club>
Tue, 12 May 2020 10:29:37 +0000 (12:29 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex
test/web/activity_pub/transmogrifier_test.exs

index 921576617fb030dc06b569a9f785c9cb4bd6bddf..80701bb638fcb3228d430664491e30a233b4e54a 100644 (file)
@@ -592,6 +592,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",
@@ -601,7 +604,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
         activity_id: id
       })
     else
-      _e -> :error
+      _e ->
+        :error
     end
   end
 
index 2914c90ea06f1f75f0e35408bdac125cba93f3f8..7d39d90679d75f713c6ca7cd6ccba4911c2dd21c 100644 (file)
@@ -815,6 +815,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