feishu: harden channel action handling and align with manager capabilities

This commit is contained in:
DBT
2026-02-27 03:33:20 +00:00
parent 2f8fad5671
commit 371164ab9d

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"sync"
"time"
@@ -27,6 +28,15 @@ type FeishuChannel struct {
runCancel cancelGuard
}
func (c *FeishuChannel) SupportsAction(action string) bool {
switch strings.ToLower(strings.TrimSpace(action)) {
case "", "send":
return true
default:
return false
}
}
func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChannel, error) {
base := NewBaseChannel("feishu", cfg, bus, cfg.AllowFrom)
@@ -94,6 +104,10 @@ func (c *FeishuChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
if msg.ChatID == "" {
return fmt.Errorf("chat ID is empty")
}
action := strings.ToLower(strings.TrimSpace(msg.Action))
if action != "" && action != "send" {
return fmt.Errorf("unsupported feishu action: %s", action)
}
payload, err := json.Marshal(map[string]string{"text": msg.Content})
if err != nil {