From a26280b31a58e958cce3575a0917d1036290479b Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 8 Sep 2022 12:36:42 +0200 Subject: [bugfix] Fix preposterous characters reserved per URL amount (#809) * clarify docs * tidy up consts, set reserved chars much lower * update tests --- internal/typeutils/internaltofrontend.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'internal/typeutils') 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 }, } } -- cgit v1.2.3