metadata-2 (#2273)
Some checks failed
build / build (push) Has been cancelled
ghcr / Build (push) Has been cancelled

Initial implementation of draft/metadata-2
This commit is contained in:
thatcher-gaming 2025-06-15 09:06:45 +01:00 committed by GitHub
parent 0f5603eca2
commit 4dcbc48159
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 660 additions and 3 deletions

View file

@ -723,6 +723,14 @@ type Config struct {
} `yaml:"tagmsg-storage"`
}
Metadata struct {
// BeforeConnect int `yaml:"before-connect"` todo: this
Enabled bool
MaxSubs int `yaml:"max-subs"`
MaxKeys int `yaml:"max-keys"`
MaxValueBytes int `yaml:"max-value-length"` // todo: currently unenforced!!
}
WebPush struct {
Enabled bool
Timeout time.Duration
@ -1637,6 +1645,25 @@ func LoadConfig(filename string) (config *Config, err error) {
}
}
if !config.Metadata.Enabled {
config.Server.supportedCaps.Disable(caps.Metadata)
} else {
var metadataValues []string
if config.Metadata.MaxSubs >= 0 {
metadataValues = append(metadataValues, fmt.Sprintf("max-subs=%d", config.Metadata.MaxSubs))
}
if config.Metadata.MaxKeys > 0 {
metadataValues = append(metadataValues, fmt.Sprintf("max-keys=%d", config.Metadata.MaxKeys))
}
if config.Metadata.MaxValueBytes > 0 {
metadataValues = append(metadataValues, fmt.Sprintf("max-value-bytes=%d", config.Metadata.MaxValueBytes))
}
if len(metadataValues) != 0 {
config.Server.capValues[caps.Metadata] = strings.Join(metadataValues, ",")
}
}
err = config.processExtjwt()
if err != nil {
return nil, err