summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/api/swagger.yaml29
-rw-r--r--internal/api/model/instancev2.go16
-rw-r--r--internal/typeutils/internaltofrontend.go6
-rw-r--r--internal/typeutils/internaltofrontend_test.go9
4 files changed, 58 insertions, 2 deletions
diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml
index 3ef284ef1..062be9d94 100644
--- a/docs/api/swagger.yaml
+++ b/docs/api/swagger.yaml
@@ -2108,6 +2108,20 @@ definitions:
example: <p>Registrations are currently closed on example.org because of spam bots!</p>
type: string
x-go-name: Message
+ min_age:
+ description: |-
+ A minimum age required to register, if configured.
+ Currently not implemented: will always be null.
+ format: int64
+ type: integer
+ x-go-name: MinAge
+ reason_required:
+ description: |-
+ Whether registrations require the user to provide a reason for joining.
+ Only applicable when ApprovalRequired is true.
+ example: true
+ type: boolean
+ x-go-name: ReasonRequired
title: Information about registering for this instance.
type: object
x-go-name: InstanceV2Registrations
@@ -2178,11 +2192,26 @@ definitions:
x-go-package: code.superseriousbusiness.org/gotosocial/internal/api/model
instanceV2URLs:
properties:
+ about:
+ description: Address of the server about page.
+ example: https://example.org/about
+ type: string
+ x-go-name: About
+ privacy_policy:
+ description: Address of the server privacy policy, if any.
+ example: https://example.org/about#rules
+ type: string
+ x-go-name: PrivacyPolicy
streaming:
description: Websockets address for status and notification streaming.
example: wss://example.org
type: string
x-go-name: Streaming
+ terms_of_service:
+ description: Address of the server current terms of service, if any.
+ example: https://example.org/about#privacy_policy
+ type: string
+ x-go-name: TermsOfService
title: InstanceV2URLs models instance-relevant URLs for client application consumption.
type: object
x-go-name: InstanceV2URLs
diff --git a/internal/api/model/instancev2.go b/internal/api/model/instancev2.go
index 5aad6f015..ba8edac47 100644
--- a/internal/api/model/instancev2.go
+++ b/internal/api/model/instancev2.go
@@ -150,6 +150,15 @@ type InstanceV2URLs struct {
// Websockets address for status and notification streaming.
// example: wss://example.org
Streaming string `json:"streaming"`
+ // Address of the server about page.
+ // example: https://example.org/about
+ About string `json:"about"`
+ // Address of the server privacy policy, if any.
+ // example: https://example.org/about#rules
+ PrivacyPolicy *string `json:"privacy_policy"`
+ // Address of the server current terms of service, if any.
+ // example: https://example.org/about#privacy_policy
+ TermsOfService *string `json:"terms_of_service"`
}
// Hints related to translation.
@@ -199,6 +208,13 @@ type InstanceV2Registrations struct {
// Value will be null if no message is set.
// example: <p>Registrations are currently closed on example.org because of spam bots!</p>
Message *string `json:"message"`
+ // A minimum age required to register, if configured.
+ // Currently not implemented: will always be null.
+ MinAge *int `json:"min_age"`
+ // Whether registrations require the user to provide a reason for joining.
+ // Only applicable when ApprovalRequired is true.
+ // example: true
+ ReasonRequired bool `json:"reason_required"`
}
// Hints related to contacting a representative of the instance.
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index ecf817c66..b6cb2bb37 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -1889,8 +1889,12 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins
instance.Thumbnail = thumbnail
+ termsOfService := config.GetProtocol() + "://" + i.Domain + "/about#rules"
+
// configuration
instance.Configuration.URLs.Streaming = "wss://" + i.Domain
+ instance.Configuration.URLs.About = config.GetProtocol() + "://" + i.Domain + "/about"
+ instance.Configuration.URLs.TermsOfService = &termsOfService
instance.Configuration.Statuses.MaxCharacters = config.GetStatusesMaxChars()
instance.Configuration.Statuses.MaxMediaAttachments = config.GetStatusesMediaMaxFiles()
instance.Configuration.Statuses.CharactersReservedPerURL = instanceStatusesCharactersReservedPerURL
@@ -1936,6 +1940,8 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins
instance.Registrations.Enabled = config.GetAccountsRegistrationOpen()
instance.Registrations.ApprovalRequired = true // always required
instance.Registrations.Message = nil // todo: not implemented
+ instance.Registrations.MinAge = nil // not implemented
+ instance.Registrations.ReasonRequired = config.GetAccountsReasonRequired()
// contact
instance.Contact.Email = i.ContactEmail
diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go
index d19bd6a2f..03d812556 100644
--- a/internal/typeutils/internaltofrontend_test.go
+++ b/internal/typeutils/internaltofrontend_test.go
@@ -2521,7 +2521,10 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
],
"configuration": {
"urls": {
- "streaming": "wss://localhost:8080"
+ "streaming": "wss://localhost:8080",
+ "about": "http://localhost:8080/about",
+ "privacy_policy": null,
+ "terms_of_service": "http://localhost:8080/about#rules"
},
"accounts": {
"allow_custom_css": true,
@@ -2587,7 +2590,9 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
"registrations": {
"enabled": true,
"approval_required": true,
- "message": null
+ "message": null,
+ "min_age": null,
+ "reason_required": true
},
"contact": {
"email": "admin@example.org",