logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: 4f8e0170e98cb91e11e70a5cb7dc3972b3035599
parent: 4c044f62258b33a95b8281e1eb42a5e0ce47d42d
Author: feld <feld@feld.me>
Date:   Thu,  2 Jul 2020 18:12:03 +0000

Merge branch 'activation-meta' into 'develop'

Add more FE-required fields to /api/v1/instance

See merge request pleroma/pleroma!2613

Diffstat:

MCHANGELOG.md1+
Mdocs/API/differences_in_mastoapi_responses.md1+
Mlib/pleroma/web/mastodon_api/views/instance_view.ex13++++++++++++-
Mtest/web/mastodon_api/controllers/instance_controller_test.exs2++
4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **Breaking:** Emoji API: changed methods and renamed routes. - Streaming: Repeats of a user's posts will no longer be pushed to the user's stream. +- Mastodon API: Added `pleroma.metadata.fields_limits` to /api/v1/instance </details> <details> diff --git 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 diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -36,8 +36,10 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do background_image: Keyword.get(instance, :background_image), pleroma: %{ 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) } @@ -88,4 +90,13 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do end |> Map.put(:enabled, Config.get([:instance, :federating])) end + + def fields_limits do + %{ + 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 diff --git a/test/web/mastodon_api/controllers/instance_controller_test.exs b/test/web/mastodon_api/controllers/instance_controller_test.exs @@ -35,8 +35,10 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest 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