From cc313f58cbd6e611f8987bcb6755bfcb4ece7040 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:23:22 +0200 Subject: [PATCH] [bugfix] serialize instance terms via API (#2293) --- internal/api/model/instancev1.go | 2 ++ internal/api/model/instancev2.go | 2 ++ internal/typeutils/internaltofrontend.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/internal/api/model/instancev1.go b/internal/api/model/instancev1.go index 3b3d215b0..2e5fef123 100644 --- a/internal/api/model/instancev1.go +++ b/internal/api/model/instancev1.go @@ -90,6 +90,8 @@ type InstanceV1 struct { MaxTootChars uint `json:"max_toot_chars"` // An itemized list of rules for this instance. Rules []InstanceRule `json:"rules"` + // Terms and conditions for accounts on this instance. + Terms string `json:"terms,omitempty"` } // InstanceV1URLs models instance-relevant URLs for client application consumption. diff --git a/internal/api/model/instancev2.go b/internal/api/model/instancev2.go index 3099b36c4..6af657813 100644 --- a/internal/api/model/instancev2.go +++ b/internal/api/model/instancev2.go @@ -64,6 +64,8 @@ type InstanceV2 struct { Contact InstanceV2Contact `json:"contact"` // An itemized list of rules for this instance. Rules []InstanceRule `json:"rules"` + // Terms and conditions for accounts on this instance. + Terms string `json:"terms,omitempty"` } // Usage data for this instance. diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 155863e34..d663a1237 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -805,6 +805,7 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins InvitesEnabled: false, // todo: not supported yet MaxTootChars: uint(config.GetStatusesMaxChars()), Rules: c.InstanceRulesToAPIRules(i.Rules), + Terms: i.Terms, } if config.GetInstanceInjectMastodonVersion() { @@ -909,6 +910,7 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins Usage: apimodel.InstanceV2Usage{}, // todo: not implemented Languages: []string{}, // todo: not implemented Rules: c.InstanceRulesToAPIRules(i.Rules), + Terms: i.Terms, } if config.GetInstanceInjectMastodonVersion() {