From d2f6cc1445392f8d49e2922ce3a769b9b314fcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Fri, 29 Aug 2025 04:39:39 +0200 Subject: [PATCH] Use separate schemas for muted/blocked accounts lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- changelog.d/blocked-muted-swagger.change | 1 + .../api_spec/operations/account_operation.ex | 46 ++++++++++++++++++- lib/pleroma/web/api_spec/schemas/account.ex | 2 - 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 changelog.d/blocked-muted-swagger.change diff --git a/changelog.d/blocked-muted-swagger.change b/changelog.d/blocked-muted-swagger.change new file mode 100644 index 000000000..12bba8612 --- /dev/null +++ b/changelog.d/blocked-muted-swagger.change @@ -0,0 +1 @@ +Use separate schemas for muted/blocked accounts lists \ No newline at end of file diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex index 620fd171b..b7fa12ba8 100644 --- a/lib/pleroma/web/api_spec/operations/account_operation.ex +++ b/lib/pleroma/web/api_spec/operations/account_operation.ex @@ -483,7 +483,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do security: [%{"oAuth" => ["follow", "read:mutes"]}], parameters: [with_relationships_param() | pagination_params()], responses: %{ - 200 => Operation.response("Accounts", "application/json", array_of_accounts()) + 200 => Operation.response("Accounts", "application/json", array_of_muted_accounts()) } } end @@ -497,7 +497,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do security: [%{"oAuth" => ["read:blocks"]}], parameters: [with_relationships_param() | pagination_params()], responses: %{ - 200 => Operation.response("Accounts", "application/json", array_of_accounts()) + 200 => Operation.response("Accounts", "application/json", array_of_blocked_accounts()) } } end @@ -896,6 +896,48 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do } end + def array_of_muted_accounts do + %Schema{ + title: "ArrayOfMutedAccounts", + type: :array, + items: %Schema{ + title: "MutedAccount", + description: "Response schema for a muted account", + allOf: [ + Account, + %Schema{ + type: :object, + properties: %{ + mute_expires_at: %Schema{type: :string, format: "date-time", nullable: true} + } + } + ] + }, + example: [Account.schema().example] + } + end + + def array_of_blocked_accounts do + %Schema{ + title: "ArrayOfBlockedAccounts", + type: :array, + items: %Schema{ + title: "BlockedAccount", + description: "Response schema for a blocked account", + allOf: [ + Account, + %Schema{ + type: :object, + properties: %{ + block_expires_at: %Schema{type: :string, format: "date-time", nullable: true} + } + } + ] + }, + example: [Account.schema().example] + } + end + defp array_of_relationships do %Schema{ title: "ArrayOfRelationships", diff --git a/lib/pleroma/web/api_spec/schemas/account.ex b/lib/pleroma/web/api_spec/schemas/account.ex index 19827e996..7d0b83afe 100644 --- a/lib/pleroma/web/api_spec/schemas/account.ex +++ b/lib/pleroma/web/api_spec/schemas/account.ex @@ -33,8 +33,6 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do header: %Schema{type: :string, format: :uri}, id: FlakeID, locked: %Schema{type: :boolean}, - mute_expires_at: %Schema{type: :string, format: "date-time", nullable: true}, - block_expires_at: %Schema{type: :string, format: "date-time", nullable: true}, note: %Schema{type: :string, format: :html}, statuses_count: %Schema{type: :integer}, url: %Schema{type: :string, format: :uri},