From a37b3ba3ff763606b01131f34f38b4693c75dda7 Mon Sep 17 00:00:00 2001 From: Jared Mahotiere Date: Mon, 23 Feb 2026 13:21:39 -0500 Subject: [PATCH] fix(wecom): guard dedup map cleanup under mutex --- pkg/channels/wecom.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/channels/wecom.go b/pkg/channels/wecom.go index f8daf89de..863efd79a 100644 --- a/pkg/channels/wecom.go +++ b/pkg/channels/wecom.go @@ -339,14 +339,15 @@ func (c *WeComBotChannel) processMessage(ctx context.Context, msg WeComBotMessag return } c.processedMsgs[msgID] = true - c.msgMu.Unlock() - // Clean up old messages periodically (keep last 1000) + // Clean up old messages periodically (keep last 1000). + // Keep the current message id in the new map to preserve dedup behavior. if len(c.processedMsgs) > 1000 { - c.msgMu.Lock() - c.processedMsgs = make(map[string]bool) - c.msgMu.Unlock() + c.processedMsgs = map[string]bool{ + msgID: true, + } } + c.msgMu.Unlock() senderID := msg.From.UserID