diff options
author | 2022-09-08 12:36:42 +0200 | |
---|---|---|
committer | 2022-09-08 12:36:42 +0200 | |
commit | a26280b31a58e958cce3575a0917d1036290479b (patch) | |
tree | b3949e08be67ce6f0b4cb4485e588b86ecb2d714 /internal/typeutils/internaltofrontend.go | |
parent | [feature] opengraph meta tags (#806) (diff) | |
download | gotosocial-a26280b31a58e958cce3575a0917d1036290479b.tar.xz |
[bugfix] Fix preposterous characters reserved per URL amount (#809)
* clarify docs
* tidy up consts, set reserved chars much lower
* update tests
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 0243e4732..a3496bb33 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -32,6 +32,15 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/util" ) +const ( + instanceStatusesCharactersReservedPerURL = 25 + instanceMediaAttachmentsImageMatrixLimit = 16777216 // width * height + instanceMediaAttachmentsVideoMatrixLimit = 16777216 // width * height + instanceMediaAttachmentsVideoFrameRateLimit = 60 + instancePollsMinExpiration = 300 // seconds + instancePollsMaxExpiration = 2629746 // seconds +) + func (c *converter) AccountToAPIAccountSensitive(ctx context.Context, a *gtsmodel.Account) (*model.Account, error) { // we can build this sensitive account easily by first getting the public account.... apiAccount, err := c.AccountToAPIAccountPublic(ctx, a) @@ -653,21 +662,21 @@ func (c *converter) InstanceToAPIInstance(ctx context.Context, i *gtsmodel.Insta Statuses: &model.InstanceConfigurationStatuses{ MaxCharacters: config.GetStatusesMaxChars(), MaxMediaAttachments: config.GetStatusesMediaMaxFiles(), - CharactersReservedPerURL: 999, + CharactersReservedPerURL: instanceStatusesCharactersReservedPerURL, }, MediaAttachments: &model.InstanceConfigurationMediaAttachments{ SupportedMimeTypes: media.AllSupportedMIMETypes(), ImageSizeLimit: config.GetMediaImageMaxSize(), - ImageMatrixLimit: 16777216, // height*width + ImageMatrixLimit: instanceMediaAttachmentsImageMatrixLimit, // height*width VideoSizeLimit: config.GetMediaVideoMaxSize(), - VideoFrameRateLimit: 60, - VideoMatrixLimit: 16777216, // height*width + VideoFrameRateLimit: instanceMediaAttachmentsVideoFrameRateLimit, + VideoMatrixLimit: instanceMediaAttachmentsVideoMatrixLimit, // height*width }, Polls: &model.InstanceConfigurationPolls{ MaxOptions: config.GetStatusesPollMaxOptions(), MaxCharactersPerOption: config.GetStatusesPollOptionMaxChars(), - MinExpiration: 300, // seconds - MaxExpiration: 2629746, // seconds + MinExpiration: instancePollsMinExpiration, // seconds + MaxExpiration: instancePollsMaxExpiration, // seconds }, } } |