From 68406f4a44be579f32f5ff7b45eaa89ea9fa330b Mon Sep 17 00:00:00 2001 From: viettranx Date: Tue, 24 Mar 2026 21:43:25 +0700 Subject: [PATCH] fix(slack): prevent app_mention from blocking message handler dedup key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the requireMention early-return check before the dedup LoadOrStore in handleAppMention. Previously, when requireMention=false, an app_mention event arriving before its corresponding message event would store the dedup key and return early without processing — causing the message handler to see the key as already loaded and silently drop the message (~50% of @mentions lost). --- internal/channels/slack/handlers_mention.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/channels/slack/handlers_mention.go b/internal/channels/slack/handlers_mention.go index 62b6ecd3..8991adb5 100644 --- a/internal/channels/slack/handlers_mention.go +++ b/internal/channels/slack/handlers_mention.go @@ -21,14 +21,17 @@ func (c *Channel) handleAppMention(ev *slackevents.AppMentionEvent) { return } - // Dedup: app_mention may arrive alongside a message event - dedupKey := ev.Channel + ":" + ev.TimeStamp - if _, loaded := c.dedup.LoadOrStore(dedupKey, time.Now()); loaded { + // If requireMention is false, message handler already processes all channel messages. + // Return BEFORE storing dedup key so we don't block the message handler. + if !c.requireMention { return } - // If requireMention is false, message handler already processes all channel messages - if !c.requireMention { + // Dedup: app_mention may arrive alongside a message event. + // Shares the same key format as handleMessage so whichever arrives first + // processes the mention; the other is safely dropped. + dedupKey := ev.Channel + ":" + ev.TimeStamp + if _, loaded := c.dedup.LoadOrStore(dedupKey, time.Now()); loaded { return }