Merge branch 'mastodon-instance-v2' into 'develop'

Add new values to /api/v2/instance

Closes #3250 and #3251

See merge request pleroma/pleroma!4106
This commit is contained in:
feld 2024-05-11 12:11:00 +00:00
commit c954437cc0
3 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1 @@
Add new parameters to /api/v2/instance: configuration[accounts][max_pinned_statuses] and configuration[statuses][characters_reserved_per_url]

View File

@ -50,6 +50,15 @@ defp instance do
%Schema{ %Schema{
type: :object, type: :object,
properties: %{ 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"}, uri: %Schema{type: :string, description: "The domain name of the instance"},
title: %Schema{type: :string, description: "The title of the website"}, title: %Schema{type: :string, description: "The title of the website"},
description: %Schema{ description: %Schema{
@ -272,6 +281,19 @@ defp instance2 do
type: :object, type: :object,
description: "Instance configuration", description: "Instance configuration",
properties: %{ 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{ urls: %Schema{
type: :object, type: :object,
properties: %{ properties: %{
@ -285,6 +307,11 @@ defp instance2 do
type: :object, type: :object,
description: "A map with poll limits for local statuses", description: "A map with poll limits for local statuses",
properties: %{ 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{ max_characters: %Schema{
type: :integer, type: :integer,
description: "Posts character limit (CW/Subject included in the counter)" description: "Posts character limit (CW/Subject included in the counter)"

View File

@ -213,6 +213,8 @@ defp configuration do
defp configuration2 do defp configuration2 do
configuration() configuration()
|> put_in([:accounts, :max_pinned_statuses], Config.get([:instance, :max_pinned_statuses], 0))
|> put_in([:statuses, :characters_reserved_per_url], 0)
|> Map.merge(%{ |> Map.merge(%{
urls: %{ urls: %{
streaming: Pleroma.Web.Endpoint.websocket_url(), streaming: Pleroma.Web.Endpoint.websocket_url(),