diff options
author | lain <lain@soykaf.club> | 2023-02-09 19:23:29 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2023-02-09 19:23:29 +0000 |
commit | 724bf7c6474d4ec37c8713d9eec634dec62e8614 (patch) | |
tree | 91c8d57f8547caac382e761b722e05b0edcd5fe0 | |
parent | 50abb54d15bb52c510ccacadc6a76c38455cc39c (diff) | |
parent | bc7ec431795ffb096648902fdd30047cfdb64b4f (diff) | |
download | pleroma-724bf7c6474d4ec37c8713d9eec634dec62e8614.tar.gz pleroma-724bf7c6474d4ec37c8713d9eec634dec62e8614.zip |
Merge branch 'tusooa/3055-instance-languages' into 'develop'
Allow customizing instance languages
Closes #3055
See merge request pleroma/pleroma!3835
-rw-r--r-- | config/description.exs | 9 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/instance_view.ex | 2 | ||||
-rw-r--r-- | test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs | 14 |
3 files changed, 24 insertions, 1 deletions
diff --git a/config/description.exs b/config/description.exs index bf4734426..78dc8770d 100644 --- a/config/description.exs +++ b/config/description.exs @@ -1052,6 +1052,15 @@ config :pleroma, :config_description, [ description: "Minimum required age (in days) for users to create account. Only used if birthday is required.", suggestions: [6570] + }, + %{ + key: :languages, + type: {:list, :string}, + description: + "Languages to be exposed in /api/v1/instance. Should be in the format of BCP47 language codes.", + suggestions: [ + "en" + ] } ] }, diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 917725839..abf7f29ab 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -27,7 +27,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do thumbnail: URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :instance_thumbnail)) |> to_string, - languages: ["en"], + languages: Keyword.get(instance, :languages, ["en"]), registrations: Keyword.get(instance, :registrations_open), approval_required: Keyword.get(instance, :account_approval_required), # Extra (not present in Mastodon): diff --git a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs index 13e3ffc0a..a556ef6a8 100644 --- a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs @@ -92,4 +92,18 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do assert ["peer1.com", "peer2.com"] == Enum.sort(result) end + + test "instance languages", %{conn: conn} do + assert %{"languages" => ["en"]} = + conn + |> get("/api/v1/instance") + |> json_response_and_validate_schema(200) + + clear_config([:instance, :languages], ["aa", "bb"]) + + assert %{"languages" => ["aa", "bb"]} = + conn + |> get("/api/v1/instance") + |> json_response_and_validate_schema(200) + end end |