mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
5a35ef34ac
- Refactor channel manager with support for Sender/Receiver interfaces and hot-swappable adapters. - Implement identity routing and pre-authentication logic for inbound messages. - Update database schema to support bot pre-auth keys and extended channel session metadata. - Add Telegram and Feishu channel configuration and adapter enhancements. - Update Swagger documentation and internal handlers for channel management. Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
595 B
Go
26 lines
595 B
Go
package channel
|
|
|
|
import "strings"
|
|
|
|
type TargetHint struct {
|
|
Example string `json:"example,omitempty"`
|
|
Label string `json:"label,omitempty"`
|
|
}
|
|
|
|
type TargetSpec struct {
|
|
Format string `json:"format"`
|
|
Hints []TargetHint `json:"hints,omitempty"`
|
|
}
|
|
|
|
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
|
|
}
|