fix(wecom): guard dedup map cleanup under mutex
This commit is contained in:
parent
efb68501b9
commit
a37b3ba3ff
1 changed files with 6 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue