diff options
Diffstat (limited to 'internal/api/model')
-rw-r--r-- | internal/api/model/instance.go | 155 | ||||
-rw-r--r-- | internal/api/model/instancev1.go | 117 | ||||
-rw-r--r-- | internal/api/model/instancev2.go | 189 |
3 files changed, 337 insertions, 124 deletions
diff --git a/internal/api/model/instance.go b/internal/api/model/instance.go index 731124567..c1eec1d54 100644 --- a/internal/api/model/instance.go +++ b/internal/api/model/instance.go @@ -20,93 +20,41 @@ package model import "mime/multipart" -// Instance models information about this or another instance. +// InstanceSettingsUpdateRequest models an instance update request. // -// swagger:model instance -type Instance struct { - // The URI of the instance. - // example: https://gts.example.org - URI string `json:"uri,omitempty"` - // The domain of accounts on this instance. - // This will not necessarily be the same as - // simply the Host part of the URI. - // example: example.org - AccountDomain string `json:"account_domain,omitempty"` - // The title of the instance. - // example: GoToSocial Example Instance - Title string `json:"title,omitempty"` - // Description of the instance. - // - // Should be HTML formatted, but might be plaintext. - // - // This should be displayed on the 'about' page for an instance. - Description string `json:"description"` - // A shorter description of the instance. - // - // Should be HTML formatted, but might be plaintext. - // - // This should be displayed on the instance splash/landing page. - ShortDescription string `json:"short_description"` - // An email address that may be used for inquiries. - // example: admin@example.org - Email string `json:"email"` - // The version of GoToSocial installed on the instance. - // - // This will contain at least a semantic version number. - // - // It may also contain, after a space, the short git commit ID of the running software. - // - // example: 0.1.1 cb85f65 - Version string `json:"version"` - // Primary language of the instance. - // example: en - Languages []string `json:"languages,omitempty"` - // New account registrations are enabled on this instance. - Registrations bool `json:"registrations"` - // New account registrations require admin approval. - ApprovalRequired bool `json:"approval_required"` - // Invites are enabled on this instance. - InvitesEnabled bool `json:"invites_enabled"` - // Configuration object containing values about status limits etc. - // This key/value will be omitted for remote instances. - Configuration *InstanceConfiguration `json:"configuration,omitempty"` - // URLs of interest for client applications. - URLS *InstanceURLs `json:"urls,omitempty"` - // Statistics about the instance: number of posts, accounts, etc. - Stats map[string]int `json:"stats,omitempty"` - // URL of the instance avatar/banner image. - // example: https://example.org/files/instance/thumbnail.jpeg - Thumbnail string `json:"thumbnail"` - // MIME type of the instance thumbnail. - // example: image/png - ThumbnailType string `json:"thumbnail_type,omitempty"` - // Description of the instance thumbnail. - // example: picture of a cute lil' friendly sloth - ThumbnailDescription string `json:"thumbnail_description,omitempty"` - // Contact account for the instance. - ContactAccount *Account `json:"contact_account,omitempty"` - // Maximum allowed length of a post on this instance, in characters. - // - // This is provided for compatibility with Tusky and other apps. - // - // example: 5000 - MaxTootChars uint `json:"max_toot_chars"` +// swagger:ignore +type InstanceSettingsUpdateRequest struct { + // Title to use for the instance. Max 40 characters. + Title *string `form:"title" json:"title" xml:"title"` + // Username for the instance contact account. Must be the username of an existing admin. + ContactUsername *string `form:"contact_username" json:"contact_username" xml:"contact_username"` + // Email for reaching the instance administrator(s). + ContactEmail *string `form:"contact_email" json:"contact_email" xml:"contact_email"` + // Short description of the instance, max 500 chars. HTML formatting accepted. + ShortDescription *string `form:"short_description" json:"short_description" xml:"short_description"` + // Longer description of the instance, max 5,000 chars. HTML formatting accepted. + Description *string `form:"description" json:"description" xml:"description"` + // Terms and conditions of the instance, max 5,000 chars. HTML formatting accepted. + Terms *string `form:"terms" json:"terms" xml:"terms"` + // Image to use as the instance thumbnail. + Avatar *multipart.FileHeader `form:"thumbnail" json:"thumbnail" xml:"thumbnail"` + // Image description for the instance avatar. + AvatarDescription *string `form:"thumbnail_description" json:"thumbnail_description" xml:"thumbnail_description"` + // Image to use as the instance header. + Header *multipart.FileHeader `form:"header" json:"header" xml:"header"` } -// InstanceConfiguration models instance configuration parameters. +// InstanceConfigurationAccounts models instance account config parameters. // -// swagger:model instanceConfiguration -type InstanceConfiguration struct { - // Instance configuration pertaining to status limits. - Statuses *InstanceConfigurationStatuses `json:"statuses"` - // Instance configuration pertaining to media attachment types + size limits. - MediaAttachments *InstanceConfigurationMediaAttachments `json:"media_attachments"` - // Instance configuration pertaining to poll limits. - Polls *InstanceConfigurationPolls `json:"polls"` - // Instance configuration pertaining to accounts. - Accounts *InstanceConfigurationAccounts `json:"accounts"` - // Instance configuration pertaining to emojis. - Emojis *InstanceConfigurationEmojis `json:"emojis"` +// swagger:model instanceConfigurationAccounts +type InstanceConfigurationAccounts struct { + // Whether or not accounts on this instance are allowed to upload custom CSS for profiles and statuses. + // + // example: false + AllowCustomCSS bool `json:"allow_custom_css"` + // The maximum number of featured tags allowed for each account. + // Currently not implemented, so this is hardcoded to 10. + MaxFeaturedTags int `json:"max_featured_tags"` } // InstanceConfigurationStatuses models instance status config parameters. @@ -185,14 +133,6 @@ type InstanceConfigurationPolls struct { MaxExpiration int `json:"max_expiration"` } -// InstanceConfigurationAccounts models instance account config parameters. -type InstanceConfigurationAccounts struct { - // Whether or not accounts on this instance are allowed to upload custom CSS for profiles and statuses. - // - // example: false - AllowCustomCSS bool `json:"allow_custom_css"` -} - // InstanceConfigurationEmojis models instance emoji config parameters. type InstanceConfigurationEmojis struct { // Max allowed emoji image size in bytes. @@ -200,36 +140,3 @@ type InstanceConfigurationEmojis struct { // example: 51200 EmojiSizeLimit int `json:"emoji_size_limit"` } - -// InstanceURLs models instance-relevant URLs for client application consumption. -// -// swagger:model instanceURLs -type InstanceURLs struct { - // Websockets address for status and notification streaming. - // example: wss://example.org - StreamingAPI string `json:"streaming_api"` -} - -// InstanceSettingsUpdateRequest models an instance update request. -// -// swagger:ignore -type InstanceSettingsUpdateRequest struct { - // Title to use for the instance. Max 40 characters. - Title *string `form:"title" json:"title" xml:"title"` - // Username for the instance contact account. Must be the username of an existing admin. - ContactUsername *string `form:"contact_username" json:"contact_username" xml:"contact_username"` - // Email for reaching the instance administrator(s). - ContactEmail *string `form:"contact_email" json:"contact_email" xml:"contact_email"` - // Short description of the instance, max 500 chars. HTML formatting accepted. - ShortDescription *string `form:"short_description" json:"short_description" xml:"short_description"` - // Longer description of the instance, max 5,000 chars. HTML formatting accepted. - Description *string `form:"description" json:"description" xml:"description"` - // Terms and conditions of the instance, max 5,000 chars. HTML formatting accepted. - Terms *string `form:"terms" json:"terms" xml:"terms"` - // Image to use as the instance thumbnail. - Avatar *multipart.FileHeader `form:"thumbnail" json:"thumbnail" xml:"thumbnail"` - // Image description for the instance avatar. - AvatarDescription *string `form:"thumbnail_description" json:"thumbnail_description" xml:"thumbnail_description"` - // Image to use as the instance header. - Header *multipart.FileHeader `form:"header" json:"header" xml:"header"` -} diff --git a/internal/api/model/instancev1.go b/internal/api/model/instancev1.go new file mode 100644 index 000000000..291b3f34b --- /dev/null +++ b/internal/api/model/instancev1.go @@ -0,0 +1,117 @@ +/* + GoToSocial + Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +package model + +// InstanceV1 models information about this instance. +// +// swagger:model instanceV1 +type InstanceV1 struct { + // The URI of the instance. + // example: https://gts.example.org + URI string `json:"uri,omitempty"` + // The domain of accounts on this instance. + // This will not necessarily be the same as + // simply the Host part of the URI. + // example: example.org + AccountDomain string `json:"account_domain,omitempty"` + // The title of the instance. + // example: GoToSocial Example Instance + Title string `json:"title,omitempty"` + // Description of the instance. + // + // Should be HTML formatted, but might be plaintext. + // + // This should be displayed on the 'about' page for an instance. + Description string `json:"description"` + // A shorter description of the instance. + // + // Should be HTML formatted, but might be plaintext. + // + // This should be displayed on the instance splash/landing page. + ShortDescription string `json:"short_description"` + // An email address that may be used for inquiries. + // example: admin@example.org + Email string `json:"email"` + // The version of GoToSocial installed on the instance. + // + // This will contain at least a semantic version number. + // + // It may also contain, after a space, the short git commit ID of the running software. + // + // example: 0.1.1 cb85f65 + Version string `json:"version"` + // Primary language of the instance. + // example: en + Languages []string `json:"languages,omitempty"` + // New account registrations are enabled on this instance. + Registrations bool `json:"registrations"` + // New account registrations require admin approval. + ApprovalRequired bool `json:"approval_required"` + // Invites are enabled on this instance. + InvitesEnabled bool `json:"invites_enabled"` + // Configuration object containing values about status limits etc. + // This key/value will be omitted for remote instances. + Configuration InstanceV1Configuration `json:"configuration,omitempty"` + // URLs of interest for client applications. + URLs InstanceV1URLs `json:"urls,omitempty"` + // Statistics about the instance: number of posts, accounts, etc. + Stats map[string]int `json:"stats,omitempty"` + // URL of the instance avatar/banner image. + // example: https://example.org/files/instance/thumbnail.jpeg + Thumbnail string `json:"thumbnail"` + // MIME type of the instance thumbnail. + // example: image/png + ThumbnailType string `json:"thumbnail_type,omitempty"` + // Description of the instance thumbnail. + // example: picture of a cute lil' friendly sloth + ThumbnailDescription string `json:"thumbnail_description,omitempty"` + // Contact account for the instance. + ContactAccount *Account `json:"contact_account,omitempty"` + // Maximum allowed length of a post on this instance, in characters. + // + // This is provided for compatibility with Tusky and other apps. + // + // example: 5000 + MaxTootChars uint `json:"max_toot_chars"` +} + +// InstanceV1URLs models instance-relevant URLs for client application consumption. +// +// swagger:model instanceV1URLs +type InstanceV1URLs struct { + // Websockets address for status and notification streaming. + // example: wss://example.org + StreamingAPI string `json:"streaming_api"` +} + +// InstanceV1Configuration models instance configuration parameters. +// +// swagger:model instanceV1Configuration +type InstanceV1Configuration struct { + // Instance configuration pertaining to status limits. + Statuses InstanceConfigurationStatuses `json:"statuses"` + // Instance configuration pertaining to media attachment types + size limits. + MediaAttachments InstanceConfigurationMediaAttachments `json:"media_attachments"` + // Instance configuration pertaining to poll limits. + Polls InstanceConfigurationPolls `json:"polls"` + // Instance configuration pertaining to accounts. + Accounts InstanceConfigurationAccounts `json:"accounts"` + // Instance configuration pertaining to emojis. + Emojis InstanceConfigurationEmojis `json:"emojis"` +} diff --git a/internal/api/model/instancev2.go b/internal/api/model/instancev2.go new file mode 100644 index 000000000..df69eeffe --- /dev/null +++ b/internal/api/model/instancev2.go @@ -0,0 +1,189 @@ +/* + GoToSocial + Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +package model + +// InstanceV2 models information about this instance. +// +// swagger:model instanceV2 +type InstanceV2 struct { + // The domain of the instance. + // example: gts.example.org + Domain string `json:"domain"` + // The domain of accounts on this instance. + // This will not necessarily be the same as + // domain. + // example: example.org + AccountDomain string `json:"account_domain"` + // The title of the instance. + // example: GoToSocial Example Instance + Title string `json:"title"` + // The version of GoToSocial installed on the instance. + // + // This will contain at least a semantic version number. + // + // It may also contain, after a space, the short git commit ID of the running software. + // + // example: 0.1.1 cb85f65 + Version string `json:"version"` + // The URL for the source code of the software running on this instance, in keeping with AGPL license requirements. + // example: https://github.com/superseriousbusiness/gotosocial + SourceURL string `json:"source_url"` + // Description of the instance. + // + // Should be HTML formatted, but might be plaintext. + // + // This should be displayed on the 'about' page for an instance. + Description string `json:"description"` + // Basic anonymous usage data for this instance. + Usage InstanceV2Usage `json:"usage"` + // An image used to represent this instance. + Thumbnail InstanceV2Thumbnail `json:"thumbnail"` + // Primary languages of the instance + moderators/admins. + // example: ["en"] + Languages []string `json:"languages"` + // Configured values and limits for this instance. + Configuration InstanceV2Configuration `json:"configuration"` + // Information about registering for this instance. + Registrations InstanceV2Registrations `json:"registrations"` + // Hints related to contacting a representative of the instance. + Contact InstanceV2Contact `json:"contact"` + // An itemized list of rules for this website. + // Currently not implemented (will always be empty array). + Rules []interface{} `json:"rules"` +} + +// Usage data for this instance. +// +// swagger:model instanceV2Usage +type InstanceV2Usage struct { + Users InstanceV2Users `json:"users"` +} + +// Usage data related to users on this instance. +// +// swagger:model instanceV2Users +type InstanceV2Users struct { + // The number of active users in the past 4 weeks. + // Currently not implemented: will always be 0. + // example: 0 + ActiveMonth int `json:"active_month"` +} + +// An image used to represent this instance. +// +// swagger:model instanceV2Thumbnail +type InstanceV2Thumbnail struct { + // The URL for the thumbnail image. + // example: https://example.org/fileserver/01BPSX2MKCRVMD4YN4D71G9CP5/attachment/original/01H88X0KQ2DFYYDSWYP93VDJZA.png + URL string `json:"url"` + // MIME type of the instance thumbnail. + // Key/value not set if thumbnail image type unknown. + // example: image/png + Type string `json:"thumbnail_type,omitempty"` + // Description of the instance thumbnail. + // Key/value not set if no description available. + // example: picture of a cute lil' friendly sloth + Description string `json:"thumbnail_description,omitempty"` + // A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. + // Key/value not set if no blurhash available. + // example: UeKUpFxuo~R%0nW;WCnhF6RjaJt757oJodS$ + Blurhash string `json:"blurhash,omitempty"` + // Links to scaled resolution images, for high DPI screens. + // Key/value not set if no extra versions available. + Versions *InstanceV2ThumbnailVersions `json:"versions,omitempty"` +} + +// Links to scaled resolution images, for high DPI screens. +// +// swagger:model instanceV2ThumbnailVersions +type InstanceV2ThumbnailVersions struct { + // The URL for the thumbnail image at 1x resolution. + // Key/value not set if scaled versions not available. + Size1URL string `json:"@1x,omitempty"` + // The URL for the thumbnail image at 2x resolution. + // Key/value not set if scaled versions not available. + Size2URL string `json:"@2x,omitempty"` +} + +// InstanceV2URLs models instance-relevant URLs for client application consumption. +// +// swagger:model instanceV1URLs +type InstanceV2URLs struct { + // Websockets address for status and notification streaming. + // example: wss://example.org + Streaming string `json:"streaming"` +} + +// Hints related to translation. +// +// swagger:model instanceV2ConfigurationTranslation +type InstanceV2ConfigurationTranslation struct { + // Whether the Translations API is available on this instance. + // Not implemented so this value is always false. + Enabled bool `json:"enabled"` +} + +// Configured values and limits for this instance. +// +// swagger:model instanceV2Configuration +type InstanceV2Configuration struct { + // URLs of interest for clients apps. + URLs InstanceV2URLs `json:"urls"` + // Limits related to accounts. + Accounts InstanceConfigurationAccounts `json:"accounts"` + // Limits related to authoring statuses. + Statuses InstanceConfigurationStatuses `json:"statuses"` + // Hints for which attachments will be accepted. + MediaAttachments InstanceConfigurationMediaAttachments `json:"media_attachments"` + // Limits related to polls. + Polls InstanceConfigurationPolls `json:"polls"` + // Hints related to translation. + Translation InstanceV2ConfigurationTranslation `json:"translation"` + // Instance configuration pertaining to emojis. + Emojis InstanceConfigurationEmojis `json:"emojis"` +} + +// Information about registering for this instance. +// +// swagger:model instanceV2Registrations +type InstanceV2Registrations struct { + // Whether registrations are enabled. + // example: false + Enabled bool `json:"enabled"` + // Whether registrations require moderator approval. + // example: true + ApprovalRequired bool `json:"approval_required"` + // A custom message (html string) to be shown when registrations are closed. + // 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"` +} + +// Hints related to contacting a representative of the instance. +// +// swagger:model instanceV2Contact +type InstanceV2Contact struct { + // An email address that can be messaged regarding inquiries or issues. + // Empty string if no email address set. + // example: someone@example.org + Email string `json:"email"` + // An account that can be contacted regarding inquiries or issues. + // Key/value not present if no contact account set. + Account *Account `json:"account,omitempty"` +} |