mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] add configuration to /api/v1/instance
response (#670)
* add configuration object to api instance model * regenerate swagger docs * add func to return all supported mimes for media * add instance configuration to api serialization * fix json tags * update instance endpoint tests * fix typeutils tests * final regen of swagger docs * omitempty instance configuration
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
)
|
||||
|
||||
@@ -595,9 +596,32 @@ func (c *converter) InstanceToAPIInstance(ctx context.Context, i *gtsmodel.Insta
|
||||
mi.InvitesEnabled = false // TODO
|
||||
mi.MaxTootChars = uint(config.GetStatusesMaxChars())
|
||||
mi.URLS = &model.InstanceURLs{
|
||||
StreamingAPI: fmt.Sprintf("wss://%s", host),
|
||||
StreamingAPI: "wss://" + host,
|
||||
}
|
||||
mi.Version = config.GetSoftwareVersion()
|
||||
|
||||
// todo: remove hardcoded values and put them in config somewhere
|
||||
mi.Configuration = &model.InstanceConfiguration{
|
||||
Statuses: &model.InstanceConfigurationStatuses{
|
||||
MaxCharacters: config.GetStatusesMaxChars(),
|
||||
MaxMediaAttachments: config.GetStatusesMediaMaxFiles(),
|
||||
CharactersReservedPerURL: 999,
|
||||
},
|
||||
MediaAttachments: &model.InstanceConfigurationMediaAttachments{
|
||||
SupportedMimeTypes: media.AllSupportedMIMETypes(),
|
||||
ImageSizeLimit: config.GetMediaImageMaxSize(),
|
||||
ImageMatrixLimit: 16777216, // height*width
|
||||
VideoSizeLimit: config.GetMediaVideoMaxSize(),
|
||||
VideoFrameRateLimit: 60,
|
||||
VideoMatrixLimit: 16777216, // height*width
|
||||
},
|
||||
Polls: &model.InstanceConfigurationPolls{
|
||||
MaxOptions: config.GetStatusesPollMaxOptions(),
|
||||
MaxCharactersPerOption: config.GetStatusesPollOptionMaxChars(),
|
||||
MinExpiration: 300, // seconds
|
||||
MaxExpiration: 2629746, // seconds
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// get the instance account if it exists and just skip if it doesn't
|
||||
|
Reference in New Issue
Block a user