[bugfix] Allow instance thumbnail description to be set separately from image (#1417)

This commit is contained in:
tobi
2023-02-04 15:53:11 +01:00
committed by GitHub
parent 04ac3f8acf
commit 80c26d61f7
3 changed files with 212 additions and 171 deletions

View File

@ -178,19 +178,17 @@ func validateInstanceUpdate(form *apimodel.InstanceSettingsUpdateRequest) error
return errors.New("empty form submitted")
}
maxImageSize := config.GetMediaImageMaxSize()
maxDescriptionChars := config.GetMediaDescriptionMaxChars()
// validate avatar if present
if form.Avatar != nil {
maxImageSize := config.GetMediaImageMaxSize()
if size := form.Avatar.Size; size > int64(maxImageSize) {
return fmt.Errorf("file size limit exceeded: limit is %d bytes but desired instance avatar was %d bytes", maxImageSize, size)
}
}
if form.AvatarDescription != nil {
if length := len([]rune(*form.AvatarDescription)); length > maxDescriptionChars {
return fmt.Errorf("avatar description length must be less than %d characters (inclusive), but provided avatar description was %d chars", maxDescriptionChars, length)
}
if form.AvatarDescription != nil {
maxDescriptionChars := config.GetMediaDescriptionMaxChars()
if length := len([]rune(*form.AvatarDescription)); length > maxDescriptionChars {
return fmt.Errorf("avatar description length must be less than %d characters (inclusive), but provided avatar description was %d chars", maxDescriptionChars, length)
}
}