|  | 
| 3 | 3 | 
 | 
| 4 | 4 | package setting | 
| 5 | 5 | 
 | 
| 6 |  | -// Attachment settings | 
| 7 |  | -var Attachment = struct { | 
|  | 6 | +type AttachmentSettingType struct { | 
| 8 | 7 | 	Storage      *Storage | 
| 9 | 8 | 	AllowedTypes string | 
| 10 | 9 | 	MaxSize      int64 | 
| 11 | 10 | 	MaxFiles     int | 
| 12 | 11 | 	Enabled      bool | 
| 13 |  | -}{ | 
| 14 |  | -	Storage:      &Storage{}, | 
| 15 |  | -	AllowedTypes: ".cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip", | 
| 16 |  | -	MaxSize:      2048, | 
| 17 |  | -	MaxFiles:     5, | 
| 18 |  | -	Enabled:      true, | 
| 19 | 12 | } | 
| 20 | 13 | 
 | 
|  | 14 | +var Attachment AttachmentSettingType | 
|  | 15 | + | 
| 21 | 16 | func loadAttachmentFrom(rootCfg ConfigProvider) (err error) { | 
|  | 17 | +	Attachment = AttachmentSettingType{ | 
|  | 18 | +		AllowedTypes: ".avif,.cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.webp,.xls,.xlsx,.zip", | 
|  | 19 | +		MaxSize:      2048, | 
|  | 20 | +		MaxFiles:     5, | 
|  | 21 | +		Enabled:      true, | 
|  | 22 | +	} | 
| 22 | 23 | 	sec, _ := rootCfg.GetSection("attachment") | 
| 23 | 24 | 	if sec == nil { | 
| 24 | 25 | 		Attachment.Storage, err = getStorage(rootCfg, "attachments", "", nil) | 
| 25 | 26 | 		return err | 
| 26 | 27 | 	} | 
| 27 | 28 | 
 | 
| 28 |  | -	Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(".cpuprofile,.csv,.dmp,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.json,.jsonc,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip") | 
| 29 |  | -	Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(2048) | 
| 30 |  | -	Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(5) | 
| 31 |  | -	Attachment.Enabled = sec.Key("ENABLED").MustBool(true) | 
| 32 |  | - | 
|  | 29 | +	Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(Attachment.AllowedTypes) | 
|  | 30 | +	Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(Attachment.MaxSize) | 
|  | 31 | +	Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(Attachment.MaxFiles) | 
|  | 32 | +	Attachment.Enabled = sec.Key("ENABLED").MustBool(Attachment.Enabled) | 
| 33 | 33 | 	Attachment.Storage, err = getStorage(rootCfg, "attachments", "", sec) | 
| 34 | 34 | 	return err | 
| 35 | 35 | } | 
0 commit comments