Add support for setting language in instance metadata (#183)
authorfloatingghost <hannah@coffee-and-dreams.uk>
Thu, 25 Aug 2022 16:11:21 +0000 (16:11 +0000)
committerfloatingghost <hannah@coffee-and-dreams.uk>
Thu, 25 Aug 2022 16:11:21 +0000 (16:11 +0000)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/183

CHANGELOG.md
config/config.exs
config/description.exs
lib/pleroma/web/mastodon_api/views/instance_view.ex
test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs

index 3966bb10ba44ac0de45ce5d66e17bc2b2d9cea5a..df34d2bb6e6092958d516fc8cdaee1a9e294951c 100644 (file)
@@ -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
index 83977da19b59c6aa547de95ff80685a9172c3210..ec82e872a9f5787a7aa78859e4cd0b241f3c974d 100644 (file)
@@ -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,
index b70982cd2a05799a3921ac65992ab8b2a7b9619d..61ef8f4493c81ac3047effb03d0d091a16026033 100644 (file)
@@ -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",
index 4cfa8d85ca0e04083a52f16bc77c04e3776618d7..7ae357e2369239dad4b2f6541a1d0a7995a01a67 100644 (file)
@@ -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):
index 90801a90a86450410cb49cfe31bded6dd60f4e33..bc3d358193fcb37e8ce49ee1a9217c20f5cf17ef 100644 (file)
@@ -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" => _,