Use reject_follow_request

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-03-16 18:38:28 +01:00 committed by FloatingGhost
parent 49f2cd6932
commit f2ef0de6d9
2 changed files with 6 additions and 3 deletions

View File

@ -453,9 +453,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
{:error, "Can not unfollow yourself"}
end
def remove_from_followers(%{assigns: %{user: follower, account: followed}} = conn, _params) do
with {:ok, follower} <- CommonAPI.unfollow(followed, follower) do
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)
else
nil ->
render_error(conn, :not_found, "Record not found")
end
end

View File

@ -1930,7 +1930,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
CommonAPI.follow(other_user, user)
assert %{"id" => _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)