Unilateral remove from followers #232

Merged
floatingghost merged 5 commits from remove-from-followers into develop 2022-10-19 10:01:14 +00:00
2 changed files with 17 additions and 2 deletions
Showing only changes of commit 066ce8c6ac - Show all commits

View file

@ -455,7 +455,7 @@ def remove_from_followers(%{assigns: %{user: %{id: id}, account: %{id: id}}}, _p
def remove_from_followers(%{assigns: %{user: followed, account: follower}} = conn, _params) do
with {:ok, follower} <- CommonAPI.reject_follow_request(follower, followed) do
render(conn, "relationship.json", user: follower, target: followed)
render(conn, "relationship.json", user: followed, target: follower)
else
nil ->
render_error(conn, :not_found, "Record not found")

View file

@ -1930,7 +1930,22 @@ test "removing user from followers", %{conn: conn, user: user} do
CommonAPI.follow(other_user, user)
assert %{"id" => other_user_id, "followed_by" => false} =
assert %{"id" => ^other_user_id, "followed_by" => false} =
conn
|> post("/api/v1/accounts/#{other_user_id}/remove_from_followers")
|> json_response_and_validate_schema(200)
refute User.following?(other_user, user)
end
test "removing remote user from followers", %{conn: conn, user: user} do
%{id: other_user_id} = other_user = insert(:user, local: false)
CommonAPI.follow(other_user, user)
assert User.following?(other_user, user)
assert %{"id" => ^other_user_id, "followed_by" => false} =
conn
|> post("/api/v1/accounts/#{other_user_id}/remove_from_followers")
|> json_response_and_validate_schema(200)