From f2ef0de6d9bebda2eb43c92d5c2b201e459ec6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 16 Mar 2022 18:38:28 +0100 Subject: [PATCH] Use reject_follow_request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../web/mastodon_api/controllers/account_controller.ex | 7 +++++-- .../mastodon_api/controllers/account_controller_test.exs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index 6fb80d35c..60c27a131 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -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 diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs index c0962e699..a0615c4de 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -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)