Add support for setting language in instance metadata #183

Merged
floatingghost merged 1 commit from allow-instance-language into develop 2022-08-25 16:11:22 +00:00
5 changed files with 17 additions and 3 deletions

View file

@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ### Added
- support for fedibird-fe, and non-breaking API parity for it to function - support for fedibird-fe, and non-breaking API parity for it to function
- support for setting instance languages in metadata
- support for reusing oauth tokens, and not requiring new authorizations
### Changed ### Changed
- MFM parsing is now done on the backend by a modified version of ilja's parser -> https://akkoma.dev/AkkomaGang/mfm-parser - MFM parsing is now done on the backend by a modified version of ilja's parser -> https://akkoma.dev/AkkomaGang/mfm-parser

View file

@ -197,6 +197,7 @@
avatar_upload_limit: 2_000_000, avatar_upload_limit: 2_000_000,
background_upload_limit: 4_000_000, background_upload_limit: 4_000_000,
banner_upload_limit: 4_000_000, banner_upload_limit: 4_000_000,
languages: ["en"],
poll_limits: %{ poll_limits: %{
max_options: 20, max_options: 20,
max_option_chars: 200, max_option_chars: 200,

View file

@ -509,6 +509,16 @@
"Pleroma" "Pleroma"
] ]
}, },
%{
key: :languages,
type: {:list, :string},
description: "Languages the instance uses",
suggestions: [
"en",
"ja",
"fr"
]
},
%{ %{
key: :email, key: :email,
label: "Admin Email Address", label: "Admin Email Address",

View file

@ -26,7 +26,7 @@ def render("show.json", _) do
thumbnail: thumbnail:
URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :instance_thumbnail)) URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :instance_thumbnail))
|> to_string, |> to_string,
languages: ["en"], languages: Keyword.get(instance, :languages, ["en"]),
registrations: Keyword.get(instance, :registrations_open), registrations: Keyword.get(instance, :registrations_open),
approval_required: Keyword.get(instance, :account_approval_required), approval_required: Keyword.get(instance, :account_approval_required),
# Extra (not present in Mastodon): # Extra (not present in Mastodon):

View file

@ -10,10 +10,11 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
import Pleroma.Factory import Pleroma.Factory
test "get instance information", %{conn: conn} do test "get instance information", %{conn: conn} do
clear_config([:instance, :languages], ["en", "ja"])
conn = get(conn, "/api/v1/instance") conn = get(conn, "/api/v1/instance")
assert result = json_response_and_validate_schema(conn, 200) assert result = json_response_and_validate_schema(conn, 200)
email = Pleroma.Config.get([:instance, :email]) email = Pleroma.Config.get([:instance, :email])
thumbnail = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :instance_thumbnail]) thumbnail = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :instance_thumbnail])
background = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :background_image]) background = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :background_image])
@ -29,7 +30,7 @@ test "get instance information", %{conn: conn} do
}, },
"stats" => _, "stats" => _,
"thumbnail" => from_config_thumbnail, "thumbnail" => from_config_thumbnail,
"languages" => _, "languages" => ["en", "ja"],
"registrations" => _, "registrations" => _,
"approval_required" => _, "approval_required" => _,
"poll_limits" => _, "poll_limits" => _,