Support blocking via query parameters as well and document the change.
This commit is contained in:
parent
bdb3375933
commit
4bfad0b483
@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- **Breaking:** Notification Settings API option for hiding push notification
|
- **Breaking:** Notification Settings API option for hiding push notification
|
||||||
contents has been renamed to `hide_notification_contents`
|
contents has been renamed to `hide_notification_contents`
|
||||||
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
||||||
|
- Mastodon API (legacy): Allow query parameters for `/api/v1/domain_blocks`, e.g. `/api/v1/domain_blocks?domain=badposters.zone`
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -31,6 +31,7 @@ def index_operation do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Supporting domain query parameter is deprecated in Mastodon API
|
||||||
def create_operation do
|
def create_operation do
|
||||||
%Operation{
|
%Operation{
|
||||||
tags: ["domain_blocks"],
|
tags: ["domain_blocks"],
|
||||||
@ -45,11 +46,13 @@ def create_operation do
|
|||||||
""",
|
""",
|
||||||
operationId: "DomainBlockController.create",
|
operationId: "DomainBlockController.create",
|
||||||
requestBody: domain_block_request(),
|
requestBody: domain_block_request(),
|
||||||
|
parameters: [Operation.parameter(:domain, :query, %Schema{type: :string}, "Domain name")],
|
||||||
security: [%{"oAuth" => ["follow", "write:blocks"]}],
|
security: [%{"oAuth" => ["follow", "write:blocks"]}],
|
||||||
responses: %{200 => empty_object_response()}
|
responses: %{200 => empty_object_response()}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Supporting domain query parameter is deprecated in Mastodon API
|
||||||
def delete_operation do
|
def delete_operation do
|
||||||
%Operation{
|
%Operation{
|
||||||
tags: ["domain_blocks"],
|
tags: ["domain_blocks"],
|
||||||
|
@ -32,6 +32,11 @@ def create(%{assigns: %{user: blocker}, body_params: %{domain: domain}} = conn,
|
|||||||
json(conn, %{})
|
json(conn, %{})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create(%{assigns: %{user: blocker}} = conn, %{domain: domain}) do
|
||||||
|
User.block_domain(blocker, domain)
|
||||||
|
json(conn, %{})
|
||||||
|
end
|
||||||
|
|
||||||
@doc "DELETE /api/v1/domain_blocks"
|
@doc "DELETE /api/v1/domain_blocks"
|
||||||
def delete(%{assigns: %{user: blocker}, body_params: %{domain: domain}} = conn, _params) do
|
def delete(%{assigns: %{user: blocker}, body_params: %{domain: domain}} = conn, _params) do
|
||||||
User.unblock_domain(blocker, domain)
|
User.unblock_domain(blocker, domain)
|
||||||
|
@ -32,6 +32,20 @@ test "blocking / unblocking a domain" do
|
|||||||
refute User.blocks?(user, other_user)
|
refute User.blocks?(user, other_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "blocking a domain via query params" do
|
||||||
|
%{user: user, conn: conn} = oauth_access(["write:blocks"])
|
||||||
|
other_user = insert(:user, %{ap_id: "https://dogwhistle.zone/@pundit"})
|
||||||
|
|
||||||
|
ret_conn =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/v1/domain_blocks?domain=dogwhistle.zone")
|
||||||
|
|
||||||
|
assert %{} == json_response_and_validate_schema(ret_conn, 200)
|
||||||
|
user = User.get_cached_by_ap_id(user.ap_id)
|
||||||
|
assert User.blocks?(user, other_user)
|
||||||
|
end
|
||||||
|
|
||||||
test "unblocking a domain via query params" do
|
test "unblocking a domain via query params" do
|
||||||
%{user: user, conn: conn} = oauth_access(["write:blocks"])
|
%{user: user, conn: conn} = oauth_access(["write:blocks"])
|
||||||
other_user = insert(:user, %{ap_id: "https://dogwhistle.zone/@pundit"})
|
other_user = insert(:user, %{ap_id: "https://dogwhistle.zone/@pundit"})
|
||||||
|
Loading…
Reference in New Issue
Block a user