logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: ffe081bf4417ae7efbf24e4eaf0ee65fa2c2d8cf
parent 6754d1f27239d3d529a3f667a6a93b267041daf0
Author: marcin mikołajczak <git@mkljczk.pl>
Date:   Wed, 16 Mar 2022 18:38:28 +0100

Use reject_follow_request

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>

Diffstat:

Mlib/pleroma/web/mastodon_api/controllers/account_controller.ex7+++++--
Mtest/pleroma/web/mastodon_api/controllers/account_controller_test.exs2+-
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 @@ -479,9 +479,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 @@ -1985,7 +1985,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)