Files
Memoh/internal/channel/target.go
T
BBQ a246b79a4f refactor: restructure channel gateway and chat module architecture
- Refactor channel adapters (feishu, telegram, local) with enhanced descriptor and config
- Restructure channel manager, service, types, and outbound messaging
- Simplify chat module by removing normalize.go and chat.go, consolidating into resolver and types
- Update router channel handlers and tests
- Sync swagger documentation
2026-02-06 23:47:12 +08:00

30 lines
942 B
Go

package channel
import "strings"
// TargetHint provides a display label and example for a target format.
type TargetHint struct {
Example string `json:"example,omitempty"`
Label string `json:"label,omitempty"`
}
// TargetSpec describes the expected format of a delivery target for a channel type.
type TargetSpec struct {
Format string `json:"format"`
Hints []TargetHint `json:"hints,omitempty"`
}
// NormalizeTarget applies the channel-specific target normalization function.
// It returns the normalized string and true if a normalizer was found, otherwise the trimmed input and false.
func NormalizeTarget(channelType ChannelType, raw string) (string, bool) {
desc, ok := GetChannelDescriptor(channelType)
if !ok || desc.NormalizeTarget == nil {
return strings.TrimSpace(raw), false
}
normalized := strings.TrimSpace(desc.NormalizeTarget(raw))
if normalized == "" {
return "", false
}
return normalized, true
}