commit: 3cad57bf48180ee5f308ad491c21bcf231a7ba69
parent ffa6805c0919abca6de2329ce01966d883876b30
Author: Mark Felder <feld@feld.me>
Date:   Tue,  7 May 2024 17:23:41 -0400
Add configuration[statuses][characters_reserved_per_url] to /api/v2/instance
Fixes #3250
Diffstat:
3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/changelog.d/characters_reserved_per_url.add 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
@@ -285,6 +285,11 @@ defmodule Pleroma.Web.ApiSpec.InstanceOperation 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
@@ -213,6 +213,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
 
   defp configuration2 do
     configuration()
+    |> put_in([:statuses, :characters_reserved_per_url], 0)
     |> Map.merge(%{
       urls: %{
         streaming: Pleroma.Web.Endpoint.websocket_url(),