Merge branch 'configuration' into 'develop'
Add `configuration` field to /api/v1/instance See merge request soapbox-pub/soapbox-be!98
This commit is contained in:
commit
0a6c52fecb
3 changed files with 86 additions and 0 deletions
|
@ -141,6 +141,62 @@ defp instance do
|
|||
type: :string,
|
||||
format: :uri,
|
||||
description: "The background image for the website"
|
||||
},
|
||||
configuration: %Schema{
|
||||
type: :object,
|
||||
description: "Instance configuration",
|
||||
properties: %{
|
||||
statuses: %Schema{
|
||||
type: :object,
|
||||
description: "A map with poll limits for local statuses",
|
||||
properties: %{
|
||||
max_characters: %Schema{
|
||||
type: :integer,
|
||||
description: "Posts character limit (CW/Subject included in the counter)"
|
||||
},
|
||||
max_media_attachments: %Schema{
|
||||
type: :integer,
|
||||
description: "Media attachment limit"
|
||||
}
|
||||
}
|
||||
},
|
||||
media_attachments: %Schema{
|
||||
type: :object,
|
||||
description: "A map with poll limits for media attachments",
|
||||
properties: %{
|
||||
image_size_limit: %Schema{
|
||||
type: :integer,
|
||||
description: "File size limit of uploaded images"
|
||||
},
|
||||
video_size_limit: %Schema{
|
||||
type: :integer,
|
||||
description: "File size limit of uploaded videos"
|
||||
}
|
||||
}
|
||||
},
|
||||
polls: %Schema{
|
||||
type: :object,
|
||||
description: "A map with poll limits for local polls",
|
||||
properties: %{
|
||||
max_options: %Schema{
|
||||
type: :integer,
|
||||
description: "Maximum number of options."
|
||||
},
|
||||
max_characters_per_option: %Schema{
|
||||
type: :integer,
|
||||
description: "Maximum number of characters per option."
|
||||
},
|
||||
min_expiration: %Schema{
|
||||
type: :integer,
|
||||
description: "Minimum expiration time (in seconds)."
|
||||
},
|
||||
max_expiration: %Schema{
|
||||
type: :integer,
|
||||
description: "Maximum expiration time (in seconds)."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
example: %{
|
||||
|
|
|
@ -55,6 +55,7 @@ def render("show.json", _) do
|
|||
stats: %{mau: Pleroma.User.active_user_count()},
|
||||
vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
||||
},
|
||||
configuration: configuration(),
|
||||
soapbox: %{
|
||||
version: Soapbox.version()
|
||||
}
|
||||
|
@ -156,4 +157,23 @@ def fields_limits do
|
|||
value_length: Config.get([:instance, :account_field_value_length])
|
||||
}
|
||||
end
|
||||
|
||||
def configuration do
|
||||
%{
|
||||
statuses: %{
|
||||
max_characters: Config.get([:instance, :limit]),
|
||||
max_media_attachments: Config.get([:instance, :max_media_attachments])
|
||||
},
|
||||
media_attachments: %{
|
||||
image_size_limit: Config.get([:instance, :upload_limit]),
|
||||
video_size_limit: Config.get([:instance, :upload_limit])
|
||||
},
|
||||
polls: %{
|
||||
max_options: Config.get([:instance, :poll_limits, :max_options]),
|
||||
max_characters_per_option: Config.get([:instance, :poll_limits, :max_option_chars]),
|
||||
min_expiration: Config.get([:instance, :poll_limits, :min_expiration]),
|
||||
max_expiration: Config.get([:instance, :poll_limits, :max_expiration])
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -108,4 +108,14 @@ test "get instance rules", %{conn: conn} do
|
|||
|
||||
assert length(rules) == 3
|
||||
end
|
||||
|
||||
test "get instance configuration", %{conn: conn} do
|
||||
clear_config([:instance, :limit], 476)
|
||||
|
||||
conn = get(conn, "/api/v1/instance")
|
||||
|
||||
assert result = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
assert result["configuration"]["statuses"]["max_characters"] == 476
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue