From: floatingghost Date: Thu, 25 Aug 2022 16:11:21 +0000 (+0000) Subject: Add support for setting language in instance metadata (#183) X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=e4f2251e0f5744de66b9b3bee2a0086bc7ab2bb1;p=akkoma Add support for setting language in instance metadata (#183) Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/183 --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 3966bb10b..df34d2bb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - 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 - MFM parsing is now done on the backend by a modified version of ilja's parser -> https://akkoma.dev/AkkomaGang/mfm-parser diff --git a/config/config.exs b/config/config.exs index 83977da19..ec82e872a 100644 --- a/config/config.exs +++ b/config/config.exs @@ -197,6 +197,7 @@ config :pleroma, :instance, avatar_upload_limit: 2_000_000, background_upload_limit: 4_000_000, banner_upload_limit: 4_000_000, + languages: ["en"], poll_limits: %{ max_options: 20, max_option_chars: 200, diff --git a/config/description.exs b/config/description.exs index b70982cd2..61ef8f449 100644 --- a/config/description.exs +++ b/config/description.exs @@ -509,6 +509,16 @@ config :pleroma, :config_description, [ "Pleroma" ] }, + %{ + key: :languages, + type: {:list, :string}, + description: "Languages the instance uses", + suggestions: [ + "en", + "ja", + "fr" + ] + }, %{ key: :email, label: "Admin Email Address", diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 4cfa8d85c..7ae357e23 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -26,7 +26,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 90801a90a..bc3d35819 100644 --- a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs @@ -10,10 +10,11 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do import Pleroma.Factory test "get instance information", %{conn: conn} do + clear_config([:instance, :languages], ["en", "ja"]) conn = get(conn, "/api/v1/instance") assert result = json_response_and_validate_schema(conn, 200) - email = Pleroma.Config.get([:instance, :email]) + thumbnail = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :instance_thumbnail]) background = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :background_image]) @@ -29,7 +30,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do }, "stats" => _, "thumbnail" => from_config_thumbnail, - "languages" => _, + "languages" => ["en", "ja"], "registrations" => _, "approval_required" => _, "poll_limits" => _,