commit b7dd32da42c2bb958c6964ef3d02f936f8d31ccb
parent 6d138588d8fc450121a3230612e8cf2d9b4e9908
Author: Daenney <daenney@users.noreply.github.com>
Date: Sat, 6 May 2023 22:38:19 +0200
[bugfix] Return languages in api/v1/instance (#1741)
It turns out that in Masto v2.3.0 the languages key was added to the V1
Instance and that it's effectively mandatory. Though in GtS we don't
really have this concept yet, some apps will explode if the languages
key is missing altogether. So at least return the empty array on V1 too
in the hopes that it makes things work well enough.
For history's sake, you can see the attributes that will get serialised
in
https://github.com/mastodon/mastodon/blob/f877aa9d70d0d600961989b8e97c0e0ce3ac1db6/app/serializers/rest/v1/instance_serializer.rb#L6-L9.
Because the attribute does not have a conditional defined for it,
there isn't a filter that optionally omits it, or a def languages to
modify the behaviour the attribute is effectively always included and
serialised.
Fixes: #1662
Diffstat:
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/internal/api/client/instance/instancepatch_test.go b/internal/api/client/instance/instancepatch_test.go
@@ -82,6 +82,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch1() {
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"email": "someone@example.org",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,
@@ -184,6 +185,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch2() {
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"email": "admin@example.org",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,
@@ -286,6 +288,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch3() {
"short_description": "\u003cp\u003eThis is some html, which is \u003cem\u003eallowed\u003c/em\u003e in short descriptions.\u003c/p\u003e",
"email": "admin@example.org",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,
@@ -439,6 +442,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch6() {
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"email": "",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,
@@ -563,6 +567,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch8() {
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"email": "admin@example.org",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,
@@ -702,6 +707,7 @@ func (suite *InstancePatchTestSuite) TestInstancePatch9() {
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"email": "admin@example.org",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,
diff --git a/internal/api/model/instancev1.go b/internal/api/model/instancev1.go
@@ -57,7 +57,7 @@ type InstanceV1 struct {
Version string `json:"version"`
// Primary language of the instance.
// example: en
- Languages []string `json:"languages,omitempty"`
+ Languages []string `json:"languages"`
// New account registrations are enabled on this instance.
Registrations bool `json:"registrations"`
// New account registrations require admin approval.
diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go
@@ -497,6 +497,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() {
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
"email": "admin@example.org",
"version": "0.0.0-testrig",
+ "languages": [],
"registrations": true,
"approval_required": true,
"invites_enabled": false,