forked from AkkomaGang/akkoma
Change follow_operation schema to use type BooleanLike (#301)
Changes follow_operation schema to use BooleanLike instead of :boolean so that strings like "0" and "1" (used by mastodon.py) can be accepted. Rest of file uses the same. For more info please see https://git.pleroma.social/pleroma/pleroma/-/issues/2999 (I'm also sending this here as I'm not hopeful about upstream not ignoring it) Co-authored-by: ave <ave@ave.zone> Reviewed-on: AkkomaGang/akkoma#301 Co-authored-by: ave <ave@noreply.akkoma> Co-committed-by: ave <ave@noreply.akkoma>
This commit is contained in:
parent
4a82f19ce6
commit
1c4ca20ff7
3 changed files with 35 additions and 16 deletions
|
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
- MastoAPI: Accept BooleanLike input on `/api/v1/accounts/:id/follow` (fixes follows with mastodon.py)
|
||||||
|
|
||||||
## 2022.11
|
## 2022.11
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
@ -12,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Scraping of nodeinfo from remote instances to display instance info
|
- Scraping of nodeinfo from remote instances to display instance info
|
||||||
- `requested_by` in relationships when the user has requested to follow you
|
- `requested_by` in relationships when the user has requested to follow you
|
||||||
|
|
||||||
## Changes
|
## Changed
|
||||||
- Follows no longer override domain blocks, a domain block is final
|
- Follows no longer override domain blocks, a domain block is final
|
||||||
- Deletes are now the lowest priority to publish and will be handled after creates
|
- Deletes are now the lowest priority to publish and will be handled after creates
|
||||||
- Domain blocks are now subdomain-matches by default
|
- Domain blocks are now subdomain-matches by default
|
||||||
|
|
|
@ -223,12 +223,12 @@ def follow_operation do
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
reblogs: %Schema{
|
reblogs: %Schema{
|
||||||
type: :boolean,
|
allOf: [BooleanLike],
|
||||||
description: "Receive this account's reblogs in home timeline? Defaults to true.",
|
description: "Receive this account's reblogs in home timeline? Defaults to true.",
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
notify: %Schema{
|
notify: %Schema{
|
||||||
type: :boolean,
|
allOf: [BooleanLike],
|
||||||
description:
|
description:
|
||||||
"Receive notifications for all statuses posted by the account? Defaults to false.",
|
"Receive notifications for all statuses posted by the account? Defaults to false.",
|
||||||
default: false
|
default: false
|
||||||
|
|
|
@ -902,6 +902,12 @@ test "following without reblogs" do
|
||||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: true})
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: true})
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert %{"showing_reblogs" => true} =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: "1"})
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^reblog_id}] =
|
assert [%{"id" => ^reblog_id}] =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/timelines/home")
|
|> get("/api/v1/timelines/home")
|
||||||
|
@ -931,6 +937,12 @@ test "following with reblogs" do
|
||||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: false})
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: false})
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert %{"showing_reblogs" => false} =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: "0"})
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [] ==
|
assert [] ==
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/timelines/home")
|
|> get("/api/v1/timelines/home")
|
||||||
|
@ -941,21 +953,23 @@ test "following with subscription and unsubscribing" do
|
||||||
%{conn: conn} = oauth_access(["follow"])
|
%{conn: conn} = oauth_access(["follow"])
|
||||||
followed = insert(:user)
|
followed = insert(:user)
|
||||||
|
|
||||||
ret_conn =
|
assert %{"subscribing" => true} =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{notify: true})
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{notify: true})
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert %{"id" => _id, "subscribing" => true} =
|
assert %{"subscribing" => true} =
|
||||||
json_response_and_validate_schema(ret_conn, 200)
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{notify: "1"})
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
ret_conn =
|
assert %{"subscribing" => false} =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{notify: false})
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{notify: false})
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
assert %{"id" => _id, "subscribing" => false} =
|
|
||||||
json_response_and_validate_schema(ret_conn, 200)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "following / unfollowing errors", %{user: user, conn: conn} do
|
test "following / unfollowing errors", %{user: user, conn: conn} do
|
||||||
|
|
Loading…
Reference in a new issue