mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-11-12 10:58:49 +01:00
Merge branch '1748-remote-following-follower-count' into 'develop'
Transmogrifier: On incoming follow accept, update follow counts. Closes #1748 See merge request pleroma/pleroma!2515
This commit is contained in:
commit
4cc71aad65
@ -592,6 +592,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
{: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"]),
|
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept) do
|
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept) do
|
||||||
|
User.update_follower_count(followed)
|
||||||
|
User.update_following_count(follower)
|
||||||
|
|
||||||
ActivityPub.accept(%{
|
ActivityPub.accept(%{
|
||||||
to: follow_activity.data["to"],
|
to: follow_activity.data["to"],
|
||||||
type: "Accept",
|
type: "Accept",
|
||||||
@ -601,7 +604,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||||||
activity_id: id
|
activity_id: id
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
_e -> :error
|
_e ->
|
||||||
|
:error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -833,6 +833,12 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||||||
follower = User.get_cached_by_id(follower.id)
|
follower = User.get_cached_by_id(follower.id)
|
||||||
|
|
||||||
assert User.following?(follower, followed) == true
|
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
|
end
|
||||||
|
|
||||||
test "it fails for incoming accepts which cannot be correlated" do
|
test "it fails for incoming accepts which cannot be correlated" do
|
||||||
|
Loading…
Reference in New Issue
Block a user