feat: advanced custom channel (#5590)

This commit is contained in:
Seefs
2026-06-18 18:00:27 +08:00
committed by GitHub
parent 21d4d18dfc
commit 3f2c0aeda7
26 changed files with 3012 additions and 62 deletions
+20
View File
@@ -945,6 +945,26 @@ func (channel *Channel) ValidateSettings() error {
return err
}
}
channelOtherSettings := &dto.ChannelOtherSettings{}
if channel.OtherSettings != "" {
err := common.UnmarshalJsonStr(channel.OtherSettings, channelOtherSettings)
if err != nil {
return err
}
}
if channel.Type == constant.ChannelTypeAdvancedCustom {
if channelOtherSettings.AdvancedCustom == nil {
return fmt.Errorf("advanced_custom is required")
}
if channelOtherSettings.AdvancedCustom.Fallback.Enabled && (channel.BaseURL == nil || strings.TrimSpace(*channel.BaseURL) == "") {
return fmt.Errorf("base_url is required when advanced_custom advanced_fallback is enabled")
}
}
if channelOtherSettings.AdvancedCustom != nil {
if err := channelOtherSettings.AdvancedCustom.Validate(); err != nil {
return err
}
}
return nil
}