diff --git a/pkg/channels/base.go b/pkg/channels/base.go index 063a66523..4d12772d2 100644 --- a/pkg/channels/base.go +++ b/pkg/channels/base.go @@ -10,6 +10,7 @@ import ( "sync/atomic" "time" + "github.com/sipeed/picoclaw/pkg/audit" "github.com/sipeed/picoclaw/pkg/bus" "github.com/sipeed/picoclaw/pkg/config" "github.com/sipeed/picoclaw/pkg/identity" @@ -240,10 +241,14 @@ func (c *BaseChannel) HandleMessage( } if sender.CanonicalID != "" || sender.PlatformID != "" { if !c.IsAllowedSender(sender) { + // Audit log rejected message + audit.LogMessage(ctx, "inbound_rejected", "text", content, messageID) return } } else { if !c.IsAllowed(senderID) { + // Audit log rejected message + audit.LogMessage(ctx, "inbound_rejected", "text", content, messageID) return } } diff --git a/pkg/channels/manager.go b/pkg/channels/manager.go index 155e50b39..ebec4f7d3 100644 --- a/pkg/channels/manager.go +++ b/pkg/channels/manager.go @@ -17,6 +17,7 @@ import ( "golang.org/x/time/rate" + "github.com/sipeed/picoclaw/pkg/audit" "github.com/sipeed/picoclaw/pkg/bus" "github.com/sipeed/picoclaw/pkg/config" "github.com/sipeed/picoclaw/pkg/constants" @@ -537,6 +538,9 @@ func (m *Manager) sendWithRetry(ctx context.Context, name string, w *channelWork "error": lastErr.Error(), "retries": maxRetries, }) + + // Audit log the send failure + audit.LogError(ctx, "send_failed", fmt.Sprintf("channel=%s chat_id=%s: %v", name, msg.ChatID, lastErr), false) } func (m *Manager) dispatchOutbound(ctx context.Context) {