From 954acdda2072cac343409b3d17d831b86ac6a18c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 29 May 2020 15:16:44 -0500 Subject: [PATCH 1/4] Add `account_activation_required` to /api/v1/instance --- lib/pleroma/web/mastodon_api/views/instance_view.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 6a630eafa..bb7bd2a9f 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -36,6 +36,7 @@ def render("show.json", _) do background_image: Keyword.get(instance, :background_image), pleroma: %{ metadata: %{ + account_activation_required: Keyword.get(instance, :account_activation_required), features: features(), federation: federation() }, From 5a8e0208b1cfb1995353b83338f20dc5cca195e1 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 30 Jun 2020 15:25:10 -0500 Subject: [PATCH 2/4] Add fields limits to instance metadata, add tests --- lib/pleroma/web/mastodon_api/views/instance_view.ex | 12 +++++++++++- .../controllers/instance_controller_test.exs | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 118678962..347480d49 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -38,7 +38,8 @@ def render("show.json", _) do metadata: %{ account_activation_required: Keyword.get(instance, :account_activation_required), features: features(), - federation: federation() + federation: federation(), + fields_limits: fields_limits() }, vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key) } @@ -89,4 +90,13 @@ def federation do end |> Map.put(:enabled, Config.get([:instance, :federating])) end + + def fields_limits do + %{ + maxFields: Config.get([:instance, :max_account_fields]), + maxRemoteFields: Config.get([:instance, :max_remote_account_fields]), + nameLength: Config.get([:instance, :account_field_name_length]), + valueLength: Config.get([:instance, :account_field_value_length]) + } + end end diff --git a/test/web/mastodon_api/controllers/instance_controller_test.exs b/test/web/mastodon_api/controllers/instance_controller_test.exs index 8bdfdddd1..95ee26416 100644 --- a/test/web/mastodon_api/controllers/instance_controller_test.exs +++ b/test/web/mastodon_api/controllers/instance_controller_test.exs @@ -35,8 +35,10 @@ test "get instance information", %{conn: conn} do "background_image" => _ } = result + assert result["pleroma"]["metadata"]["account_activation_required"] != nil assert result["pleroma"]["metadata"]["features"] assert result["pleroma"]["metadata"]["federation"] + assert result["pleroma"]["metadata"]["fields_limits"] assert result["pleroma"]["vapid_public_key"] assert email == from_config_email From d44ec2bf4ced0278b8cc5a0b5fa36fcfe38df38b Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 2 Jul 2020 12:55:08 -0500 Subject: [PATCH 3/4] Remove camelCase from the keys --- lib/pleroma/web/mastodon_api/views/instance_view.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 347480d49..89e48fba5 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -93,10 +93,10 @@ def federation do def fields_limits do %{ - maxFields: Config.get([:instance, :max_account_fields]), - maxRemoteFields: Config.get([:instance, :max_remote_account_fields]), - nameLength: Config.get([:instance, :account_field_name_length]), - valueLength: Config.get([:instance, :account_field_value_length]) + max_fields: Config.get([:instance, :max_account_fields]), + max_remote_fields: Config.get([:instance, :max_remote_account_fields]), + name_length: Config.get([:instance, :account_field_name_length]), + value_length: Config.get([:instance, :account_field_value_length]) } end end From 02d855b2b9a4bb88f0ddd7edc9bca30b66dbf241 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 2 Jul 2020 12:59:45 -0500 Subject: [PATCH 4/4] Document the new API extension of /api/v1/instance --- CHANGELOG.md | 1 + docs/API/differences_in_mastoapi_responses.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b6928dcd..e21318580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). API Changes - **Breaking:** Emoji API: changed methods and renamed routes. +- Added `pleroma.metadata.fields_limits` to /api/v1/instance
diff --git a/docs/API/differences_in_mastoapi_responses.md b/docs/API/differences_in_mastoapi_responses.md index 13920e5f9..72b5984ae 100644 --- a/docs/API/differences_in_mastoapi_responses.md +++ b/docs/API/differences_in_mastoapi_responses.md @@ -228,6 +228,7 @@ Has theses additional parameters (which are the same as in Pleroma-API): - `background_image`: A background image that frontends can use - `pleroma.metadata.features`: A list of supported features - `pleroma.metadata.federation`: The federation restrictions of this instance +- `pleroma.metadata.fields_limits`: A list of values detailing the length and count limitation for various instance-configurable fields. - `vapid_public_key`: The public key needed for push messages ## Markers