mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-18 22:47:31 +08:00
guard non-send message actions by channel capability
This commit is contained in:
@@ -9,6 +9,7 @@ package channels
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"clawgo/pkg/bus"
|
||||
@@ -268,6 +269,20 @@ func (m *Manager) dispatchOutbound(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
|
||||
action := strings.ToLower(strings.TrimSpace(msg.Action))
|
||||
if action == "" {
|
||||
action = "send"
|
||||
}
|
||||
if action != "send" {
|
||||
if ac, ok := channel.(ActionCapable); !ok || !ac.SupportsAction(action) {
|
||||
logger.WarnCF("channels", "Channel does not support outbound action", map[string]interface{}{
|
||||
logger.FieldChannel: msg.Channel,
|
||||
"action": action,
|
||||
})
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Bound fan-out concurrency to prevent goroutine explosion under burst traffic.
|
||||
m.dispatchSem <- struct{}{}
|
||||
go func(c Channel, outbound bus.OutboundMessage) {
|
||||
|
||||
Reference in New Issue
Block a user