mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 15:39:20 -06:00
[chore] Increase default max image description to 1500 chars, collapse cw char count into status (#2682)
* [chore] Make default max image description 1500 chars, collapse cw char count into status * oops * tests
This commit is contained in:
parent
1d51e3c8d6
commit
4b0eefbcc9
10 changed files with 19 additions and 65 deletions
|
|
@ -137,15 +137,11 @@ func validateNormalizeCreateStatus(form *apimodel.AdvancedStatusCreateForm) erro
|
|||
}
|
||||
|
||||
maxChars := config.GetStatusesMaxChars()
|
||||
maxMediaFiles := config.GetStatusesMediaMaxFiles()
|
||||
maxCwChars := config.GetStatusesCWMaxChars()
|
||||
|
||||
if form.Status != "" {
|
||||
if length := len([]rune(form.Status)); length > maxChars {
|
||||
return fmt.Errorf("status too long, %d characters provided but limit is %d", length, maxChars)
|
||||
}
|
||||
if length := len([]rune(form.Status)) + len([]rune(form.SpoilerText)); length > maxChars {
|
||||
return fmt.Errorf("status too long, %d characters provided (including spoiler/content warning) but limit is %d", length, maxChars)
|
||||
}
|
||||
|
||||
maxMediaFiles := config.GetStatusesMediaMaxFiles()
|
||||
if len(form.MediaIDs) > maxMediaFiles {
|
||||
return fmt.Errorf("too many media files attached to status, %d attached but limit is %d", len(form.MediaIDs), maxMediaFiles)
|
||||
}
|
||||
|
|
@ -156,12 +152,6 @@ func validateNormalizeCreateStatus(form *apimodel.AdvancedStatusCreateForm) erro
|
|||
}
|
||||
}
|
||||
|
||||
if form.SpoilerText != "" {
|
||||
if length := len([]rune(form.SpoilerText)); length > maxCwChars {
|
||||
return fmt.Errorf("content-warning/spoilertext too long, %d characters provided but limit is %d", length, maxCwChars)
|
||||
}
|
||||
}
|
||||
|
||||
if form.Language != "" {
|
||||
language, err := validate.Language(form.Language)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -111,8 +111,7 @@ type Configuration struct {
|
|||
StorageS3BucketName string `name:"storage-s3-bucket" usage:"Place blobs in this bucket"`
|
||||
StorageS3Proxy bool `name:"storage-s3-proxy" usage:"Proxy S3 contents through GoToSocial instead of redirecting to a presigned URL"`
|
||||
|
||||
StatusesMaxChars int `name:"statuses-max-chars" usage:"Max permitted characters for posted statuses"`
|
||||
StatusesCWMaxChars int `name:"statuses-cw-max-chars" usage:"Max permitted characters for content/spoiler warnings on statuses"`
|
||||
StatusesMaxChars int `name:"statuses-max-chars" usage:"Max permitted characters for posted statuses, including content warning"`
|
||||
StatusesPollMaxOptions int `name:"statuses-poll-max-options" usage:"Max amount of options permitted on a poll"`
|
||||
StatusesPollOptionMaxChars int `name:"statuses-poll-option-max-chars" usage:"Max amount of characters for a poll option"`
|
||||
StatusesMediaMaxFiles int `name:"statuses-media-max-files" usage:"Maximum number of media files/attachments per status"`
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ var Defaults = Configuration{
|
|||
MediaImageMaxSize: 10 * bytesize.MiB,
|
||||
MediaVideoMaxSize: 40 * bytesize.MiB,
|
||||
MediaDescriptionMinChars: 0,
|
||||
MediaDescriptionMaxChars: 500,
|
||||
MediaDescriptionMaxChars: 1500,
|
||||
MediaRemoteCacheDays: 7,
|
||||
MediaEmojiLocalMaxSize: 50 * bytesize.KiB,
|
||||
MediaEmojiRemoteMaxSize: 100 * bytesize.KiB,
|
||||
|
|
@ -87,7 +87,6 @@ var Defaults = Configuration{
|
|||
StorageS3Proxy: false,
|
||||
|
||||
StatusesMaxChars: 5000,
|
||||
StatusesCWMaxChars: 100,
|
||||
StatusesPollMaxOptions: 6,
|
||||
StatusesPollOptionMaxChars: 50,
|
||||
StatusesMediaMaxFiles: 6,
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ func (s *ConfigState) AddServerFlags(cmd *cobra.Command) {
|
|||
|
||||
// Statuses
|
||||
cmd.Flags().Int(StatusesMaxCharsFlag(), cfg.StatusesMaxChars, fieldtag("StatusesMaxChars", "usage"))
|
||||
cmd.Flags().Int(StatusesCWMaxCharsFlag(), cfg.StatusesCWMaxChars, fieldtag("StatusesCWMaxChars", "usage"))
|
||||
cmd.Flags().Int(StatusesPollMaxOptionsFlag(), cfg.StatusesPollMaxOptions, fieldtag("StatusesPollMaxOptions", "usage"))
|
||||
cmd.Flags().Int(StatusesPollOptionMaxCharsFlag(), cfg.StatusesPollOptionMaxChars, fieldtag("StatusesPollOptionMaxChars", "usage"))
|
||||
cmd.Flags().Int(StatusesMediaMaxFilesFlag(), cfg.StatusesMediaMaxFiles, fieldtag("StatusesMediaMaxFiles", "usage"))
|
||||
|
|
|
|||
|
|
@ -1525,31 +1525,6 @@ func GetStatusesMaxChars() int { return global.GetStatusesMaxChars() }
|
|||
// SetStatusesMaxChars safely sets the value for global configuration 'StatusesMaxChars' field
|
||||
func SetStatusesMaxChars(v int) { global.SetStatusesMaxChars(v) }
|
||||
|
||||
// GetStatusesCWMaxChars safely fetches the Configuration value for state's 'StatusesCWMaxChars' field
|
||||
func (st *ConfigState) GetStatusesCWMaxChars() (v int) {
|
||||
st.mutex.RLock()
|
||||
v = st.config.StatusesCWMaxChars
|
||||
st.mutex.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
// SetStatusesCWMaxChars safely sets the Configuration value for state's 'StatusesCWMaxChars' field
|
||||
func (st *ConfigState) SetStatusesCWMaxChars(v int) {
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
st.config.StatusesCWMaxChars = v
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// StatusesCWMaxCharsFlag returns the flag name for the 'StatusesCWMaxChars' field
|
||||
func StatusesCWMaxCharsFlag() string { return "statuses-cw-max-chars" }
|
||||
|
||||
// GetStatusesCWMaxChars safely fetches the value for global configuration 'StatusesCWMaxChars' field
|
||||
func GetStatusesCWMaxChars() int { return global.GetStatusesCWMaxChars() }
|
||||
|
||||
// SetStatusesCWMaxChars safely sets the value for global configuration 'StatusesCWMaxChars' field
|
||||
func SetStatusesCWMaxChars(v int) { global.SetStatusesCWMaxChars(v) }
|
||||
|
||||
// GetStatusesPollMaxOptions safely fetches the Configuration value for state's 'StatusesPollMaxOptions' field
|
||||
func (st *ConfigState) GetStatusesPollMaxOptions() (v int) {
|
||||
st.mutex.RLock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue