enbas/internal/model/instance_v2.go
Dan Anglin 42251f6df8
feat: add configuration support to enbas
SUMMARY

This commit adds configuration support to enbas. The configuration is
stored as a JSON file in the user specified configuration directory.

When using enbas for the first time, the user will first need to
execute the new init command in order to generate the configuration.
Once this has been generated the user can edit the settings to
personalise their experience, login to their account and use enbas as
normal.

For now the configurable settings included in the configuration
are as follows:

- The path to the credentials file (by default this is set to a file in
  the same directory as the configuration file).
- The path to the cache directory.
- The character limit used for line wrapping.
- The programs used for integrations such as paging, media viewing,
  opening URLs, etc.

CHANGES

- added the new config type.
- added the new init executor for generating a new configuration file.
- removed the following top level flags in favour of the new
  configration support.
    - cache-dir
    - pager
    - image-viewer
    - video-player
    - max-terminal-width
- added a new error type for use when an unknown media attachment ID
  is specified.
- updated the usage function for the executors to support a case
  where a flagsets has no flags.
- update .golangci.yaml to disable some linters
2024-06-25 12:39:39 +01:00

112 lines
4 KiB
Go

// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-or-later
package model
type InstanceV2 struct {
AccountDomain string `json:"account_domain"`
Configuration InstanceConfiguration `json:"configuration"`
Contact InstanceV2Contact `json:"contact"`
Description string `json:"description"`
DescriptionText string `json:"description_text"`
Domain string `json:"domain"`
Languages []string `json:"languages"`
Registrations InstanceV2Registrations `json:"registrations"`
Rules []InstanceRule `json:"rules"`
SourceURL string `json:"source_url"`
Terms string `json:"terms"`
TermsText string `json:"terms_text"`
Thumbnail InstanceV2Thumbnail `json:"thumbnail"`
Title string `json:"title"`
Usage InstanceV2Usage `json:"usage"`
Version string `json:"version"`
}
type InstanceConfiguration struct {
Accounts InstanceConfigurationAccounts `json:"accounts"`
Emojis InstanceConfigurationEmojis `json:"emojis"`
MediaAttachments InstanceConfigurationMediaAttachments `json:"media_attachments"`
Polls InstanceConfigurationPolls `json:"polls"`
Statuses InstanceConfigurationStatuses `json:"statuses"`
Translation InstanceV2ConfigurationTranslation `json:"translation"`
URLs InstanceV2URLs `json:"urls"`
}
type InstanceConfigurationAccounts struct {
AllowCustomCSS bool `json:"allow_custom_css"`
MaxFeaturedTags int `json:"max_featured_tags"`
MaxProfileFields int `json:"max_profile_fields"`
}
type InstanceConfigurationEmojis struct {
EmojiSizeLimit int `json:"emoji_size_limit"`
}
type InstanceConfigurationMediaAttachments struct {
ImageMatrixLimit int `json:"image_matrix_limit"`
ImageSizeLimit int `json:"image_size_limit"`
SupportedMimeTypes []string `json:"supported_mime_types"`
VideoFrameRateLimit int `json:"video_frame_rate_limit"`
VideoMatrixLimit int `json:"video_matrix_limit"`
VideoSizeLimit int `json:"video_size_limit"`
}
type InstanceConfigurationPolls struct {
MaxCharactersPerOption int `json:"max_characters_per_option"`
MaxExpiration int `json:"max_expiration"`
MaxOptions int `json:"max_options"`
MinExpiration int `json:"min_expiration"`
}
type InstanceConfigurationStatuses struct {
CharactersReservedPerURL int `json:"characters_reserved_per_url"`
MaxCharacters int `json:"max_characters"`
MaxMediaAttachments int `json:"max_media_attachments"`
SupportedMimeTypes []string `json:"supported_mime_types"`
}
type InstanceV2ConfigurationTranslation struct {
Enabled bool `json:"enabled"`
}
type InstanceV2URLs struct {
Streaming string `json:"streaming"`
}
type InstanceV2Contact struct {
Account Account `json:"account"`
Email string `json:"email"`
}
type InstanceV2Registrations struct {
ApprovalRequired bool `json:"approval_required"`
Enabled bool `json:"enabled"`
Message string `json:"message"`
}
type InstanceRule struct {
ID string `json:"id"`
Text string `json:"text"`
}
type InstanceV2Thumbnail struct {
BlurHash string `json:"blurhash"`
ThumbnailDescription string `json:"thumbnail_description"`
ThumbnailType string `json:"thumbnail_type"`
URL string `json:"url"`
Versions InstanceV2ThumbnailVersions `json:"versions"`
}
type InstanceV2ThumbnailVersions struct {
Size1URL string `json:"@1x"`
Size2URL string `json:"@2x"`
}
type InstanceV2Usage struct {
Users InstanceV2Users `json:"users"`
}
type InstanceV2Users struct {
ActiveMonth int `json:"active_month"`
}