working on updating SetAttachment to be fully Venice-compatible (in progress)

This commit is contained in:
2026-01-19 23:21:08 -07:00
parent 652cdf8477
commit 31b4a5bbd2
4 changed files with 52 additions and 5 deletions
+22 -2
View File
@@ -13,10 +13,10 @@ package config
import (
_ "embed"
"fmt"
"maps"
"os"
argparse "github.com/alexflint/go-arg"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)
@@ -88,6 +88,10 @@ type AmConfig struct {
} `yaml:"rendering"`
Posting struct {
ExternalDictionary string `yaml:"externalDictionary"`
Uploads struct {
MaxSize string `yaml:"maxSize"`
NoCompressTypes []string `yaml:"noCompressTypes"`
} `yaml:"uploads"`
} `yaml:"posting"`
}
@@ -121,6 +125,21 @@ func overlayString(loaded string, defaulted string) string {
return loaded
}
func overlayStringArray(loaded, defaulted []string) []string {
m := make(map[string]bool)
for _, s := range defaulted {
m[s] = true
}
for _, s := range loaded {
m[s] = true
}
rc := make([]string, 0, len(m))
for s := range maps.Keys(m) {
rc = append(rc, s)
}
return rc
}
/* overlayInt is a helper that takes a loaded or defaulted integer and returns it.
* Parameters:
* loaded - The integer loaded from a configuration file.
@@ -168,6 +187,8 @@ func overlayConfig(dest *AmConfig, loaded *AmConfig, defaults *AmConfig) {
dest.Rendering.CookieKey = overlayString(loaded.Rendering.CookieKey, defaults.Rendering.CookieKey)
dest.Rendering.CountryList.Prioritize = overlayString(loaded.Rendering.CountryList.Prioritize, defaults.Rendering.CountryList.Prioritize)
dest.Posting.ExternalDictionary = overlayString(loaded.Posting.ExternalDictionary, defaults.Posting.ExternalDictionary)
dest.Posting.Uploads.MaxSize = overlayString(loaded.Posting.Uploads.MaxSize, defaults.Posting.Uploads.MaxSize)
dest.Posting.Uploads.NoCompressTypes = overlayStringArray(loaded.Posting.Uploads.NoCompressTypes, defaults.Posting.Uploads.NoCompressTypes)
}
// SetupConfig loads the command line arguments, loads the config file, and prepares GlobalConfig.
@@ -188,5 +209,4 @@ func SetupConfig() {
} else {
GlobalConfig = defaultConfig // just copy over the defaults
}
log.Infof("Global config: %v", GlobalConfig)
}
+7
View File
@@ -45,3 +45,10 @@ rendering:
prioritize: US
posting:
externalDictionary: ""
uploads:
maxSize: "1M"
noCompressTypes:
- "image/gif"
- "image/jpg"
- "image/jpeg"
- "image/png"