Use reject_follow_request
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
6754d1f272
commit
ffe081bf44
|
@ -479,9 +479,12 @@ def remove_from_followers(%{assigns: %{user: %{id: id}, account: %{id: id}}}, _p
|
||||||
{:error, "Can not unfollow yourself"}
|
{:error, "Can not unfollow yourself"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_from_followers(%{assigns: %{user: follower, account: followed}} = conn, _params) do
|
def remove_from_followers(%{assigns: %{user: followed, account: follower}} = conn, _params) do
|
||||||
with {:ok, follower} <- CommonAPI.unfollow(followed, follower) do
|
with {:ok, follower} <- CommonAPI.reject_follow_request(follower, followed) do
|
||||||
render(conn, "relationship.json", user: follower, target: followed)
|
render(conn, "relationship.json", user: follower, target: followed)
|
||||||
|
else
|
||||||
|
nil ->
|
||||||
|
render_error(conn, :not_found, "Record not found")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1985,7 +1985,7 @@ test "removing user from followers", %{conn: conn, user: user} do
|
||||||
|
|
||||||
CommonAPI.follow(other_user, user)
|
CommonAPI.follow(other_user, user)
|
||||||
|
|
||||||
assert %{"id" => _id, "followed_by" => false} =
|
assert %{"id" => other_user_id, "followed_by" => false} =
|
||||||
conn
|
conn
|
||||||
|> post("/api/v1/accounts/#{other_user_id}/remove_from_followers")
|
|> post("/api/v1/accounts/#{other_user_id}/remove_from_followers")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
Loading…
Reference in New Issue