From 3cad57bf48180ee5f308ad491c21bcf231a7ba69 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 7 May 2024 17:23:41 -0400 Subject: [PATCH 1/4] Add configuration[statuses][characters_reserved_per_url] to /api/v2/instance Fixes #3250 --- changelog.d/characters_reserved_per_url.add | 1 + lib/pleroma/web/api_spec/operations/instance_operation.ex | 5 +++++ lib/pleroma/web/mastodon_api/views/instance_view.ex | 1 + 3 files changed, 7 insertions(+) create mode 100644 changelog.d/characters_reserved_per_url.add diff --git a/changelog.d/characters_reserved_per_url.add b/changelog.d/characters_reserved_per_url.add new file mode 100644 index 000000000..0ca1a2801 --- /dev/null +++ b/changelog.d/characters_reserved_per_url.add @@ -0,0 +1 @@ +Add configuration[statuses][characters_reserved_per_url] to /api/v2/instance (https://docs.joinmastodon.org/entities/Instance/#characters_reserved_per_url) diff --git a/lib/pleroma/web/api_spec/operations/instance_operation.ex b/lib/pleroma/web/api_spec/operations/instance_operation.ex index 708b74b12..57aec83a2 100644 --- a/lib/pleroma/web/api_spec/operations/instance_operation.ex +++ b/lib/pleroma/web/api_spec/operations/instance_operation.ex @@ -285,6 +285,11 @@ defp instance2 do type: :object, description: "A map with poll limits for local statuses", properties: %{ + characters_reserved_per_url: %Schema{ + type: :integer, + description: + "Each URL in a status will be assumed to be exactly this many characters." + }, max_characters: %Schema{ type: :integer, description: "Posts character limit (CW/Subject included in the counter)" diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 210b46d2c..337b2cc83 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -213,6 +213,7 @@ defp configuration do defp configuration2 do configuration() + |> put_in([:statuses, :characters_reserved_per_url], 0) |> Map.merge(%{ urls: %{ streaming: Pleroma.Web.Endpoint.websocket_url(), From b979389958e2d96212cf54ad917d55da86524e30 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 7 May 2024 17:45:02 -0400 Subject: [PATCH 2/4] Add configuration[accounts][max_pinned_statuses] to /api/v2/instance Also add the absent max_featured_tags to the api spec for /api/v2/instance --- .../web/api_spec/operations/instance_operation.ex | 13 +++++++++++++ lib/pleroma/web/mastodon_api/views/instance_view.ex | 1 + 2 files changed, 14 insertions(+) diff --git a/lib/pleroma/web/api_spec/operations/instance_operation.ex b/lib/pleroma/web/api_spec/operations/instance_operation.ex index 57aec83a2..bc37cae75 100644 --- a/lib/pleroma/web/api_spec/operations/instance_operation.ex +++ b/lib/pleroma/web/api_spec/operations/instance_operation.ex @@ -272,6 +272,19 @@ defp instance2 do type: :object, description: "Instance configuration", properties: %{ + accounts: %Schema{ + type: :object, + properties: %{ + max_featured_tags: %Schema{ + type: :integer, + description: "The maximum number of featured tags allowed for each account." + }, + max_pinned_statuses: %Schema{ + type: :integer, + description: "The maximum number of pinned statuses for each account." + } + } + }, urls: %Schema{ type: :object, properties: %{ diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 337b2cc83..890dd3977 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -213,6 +213,7 @@ defp configuration do defp configuration2 do configuration() + |> put_in([:accounts, :max_pinned_statuses], Config.get([:instance, :max_pinned_statuses], 0)) |> put_in([:statuses, :characters_reserved_per_url], 0) |> Map.merge(%{ urls: %{ From 06c26bf9c964986b9018ca843be94767f41636a3 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 7 May 2024 17:46:05 -0400 Subject: [PATCH 3/4] Add the absent max_featured_tags to the api spec for /api/v1/instance --- .../web/api_spec/operations/instance_operation.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pleroma/web/api_spec/operations/instance_operation.ex b/lib/pleroma/web/api_spec/operations/instance_operation.ex index bc37cae75..b6c411c07 100644 --- a/lib/pleroma/web/api_spec/operations/instance_operation.ex +++ b/lib/pleroma/web/api_spec/operations/instance_operation.ex @@ -50,6 +50,15 @@ defp instance do %Schema{ type: :object, properties: %{ + accounts: %Schema{ + type: :object, + properties: %{ + max_featured_tags: %Schema{ + type: :integer, + description: "The maximum number of featured tags allowed for each account." + } + } + }, uri: %Schema{type: :string, description: "The domain name of the instance"}, title: %Schema{type: :string, description: "The title of the website"}, description: %Schema{ From acf73f7e13515c64a9cfa935f6102f7ffa32585b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 7 May 2024 17:48:40 -0400 Subject: [PATCH 4/4] Update changelog entry --- changelog.d/characters_reserved_per_url.add | 1 - changelog.d/mastodon_api_v2.add | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 changelog.d/characters_reserved_per_url.add create mode 100644 changelog.d/mastodon_api_v2.add diff --git a/changelog.d/characters_reserved_per_url.add b/changelog.d/characters_reserved_per_url.add deleted file mode 100644 index 0ca1a2801..000000000 --- a/changelog.d/characters_reserved_per_url.add +++ /dev/null @@ -1 +0,0 @@ -Add configuration[statuses][characters_reserved_per_url] to /api/v2/instance (https://docs.joinmastodon.org/entities/Instance/#characters_reserved_per_url) diff --git a/changelog.d/mastodon_api_v2.add b/changelog.d/mastodon_api_v2.add new file mode 100644 index 000000000..d53aa35c4 --- /dev/null +++ b/changelog.d/mastodon_api_v2.add @@ -0,0 +1 @@ +Add new parameters to /api/v2/instance: configuration[accounts][max_pinned_statuses] and configuration[statuses][characters_reserved_per_url]