CommonAPI: Forbid disallowed status (un)muting and unpinning
When a user tried to unpin a status not belonging to them, a full MastoAPI response was sent back even if status was not visible to them. Ditto with (un)mutting except ownership.
This commit is contained in:
parent
f914748510
commit
426535bc38
4 changed files with 101 additions and 6 deletions
|
|
@ -1769,6 +1769,17 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|> json_response_and_validate_schema(404) == %{"error" => "Record not found"}
|
||||
end
|
||||
|
||||
test "/unpin: returns 422 error when activity not owned by user", %{activity: activity} do
|
||||
%{conn: conn} = oauth_access(["write:accounts"])
|
||||
|
||||
assert conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses/#{activity.id}/unpin")
|
||||
|> json_response_and_validate_schema(422) == %{
|
||||
"error" => "Someone else's status cannot be unpinned"
|
||||
}
|
||||
end
|
||||
|
||||
test "max pinned statuses", %{conn: conn, user: user, activity: activity_one} do
|
||||
{:ok, activity_two} = CommonAPI.post(user, %{status: "HI!!!"})
|
||||
|
||||
|
|
@ -1977,6 +1988,30 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|> post("/api/v1/statuses/#{activity.id}/unmute")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "cannot mute not visible conversation", %{user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Invisible!", visibility: "private"})
|
||||
%{conn: conn} = oauth_access(["write:mutes"])
|
||||
|
||||
assert conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses/#{activity.id}/mute")
|
||||
|> json_response_and_validate_schema(404) == %{
|
||||
"error" => "Record not found"
|
||||
}
|
||||
end
|
||||
|
||||
test "cannot unmute not visible conversation", %{user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "Invisible!", visibility: "private"})
|
||||
%{conn: conn} = oauth_access(["write:mutes"])
|
||||
|
||||
assert conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/statuses/#{activity.id}/unmute")
|
||||
|> json_response_and_validate_schema(404) == %{
|
||||
"error" => "Record not found"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{conn: conn} do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue