Mastodon API: do not create a following relationship if the corresponding follow request doesn't exist when calling POST /api/v1/follow_requests/:id/authorize
This commit is contained in:
parent
61889e00fc
commit
78391a00c5
2 changed files with 10 additions and 2 deletions
|
@ -39,8 +39,8 @@ def unfollow(follower, unfollowed) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_follow_request(follower, followed) do
|
def accept_follow_request(follower, followed) do
|
||||||
with {:ok, follower} <- User.follow(follower, followed),
|
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
%Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
{:ok, follower} <- User.follow(follower, followed),
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, "accept"),
|
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, "accept"),
|
||||||
{:ok, _activity} <-
|
{:ok, _activity} <-
|
||||||
|
|
|
@ -640,6 +640,14 @@ test "after rejection, it sets all existing pending follow request states to 're
|
||||||
assert Repo.get(Activity, follow_activity_two.id).data["state"] == "reject"
|
assert Repo.get(Activity, follow_activity_two.id).data["state"] == "reject"
|
||||||
assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
|
assert Repo.get(Activity, follow_activity_three.id).data["state"] == "pending"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "doesn't create a following relationship if the corresponding follow request doesn't exist" do
|
||||||
|
user = insert(:user, locked: true)
|
||||||
|
not_follower = insert(:user)
|
||||||
|
CommonAPI.accept_follow_request(not_follower, user)
|
||||||
|
|
||||||
|
assert Pleroma.FollowingRelationship.following?(not_follower, user) == false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "vote/3" do
|
describe "vote/3" do
|
||||||
|
|
Loading…
Reference in a new issue