From b69af43840cbd99839cab2437e16814b1c7b87d6 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 18 Feb 2026 00:56:04 -0500 Subject: [PATCH] fix: skip Teams messages older than 24h to prevent old channel messages surfacing --- connector_m365.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/connector_m365.go b/connector_m365.go index b165742..1cff7e7 100644 --- a/connector_m365.go +++ b/connector_m365.go @@ -754,6 +754,16 @@ func (c *M365Connector) pollTeams() bool { continue } + // Skip messages older than 24h — prevents old channel messages from surfacing + if msg.ComposeTime != "" { + if t, err := time.Parse(time.RFC3339Nano, msg.ComposeTime); err == nil { + if time.Since(t) > 24*time.Hour { + log.Printf("[m365] Skipping old Teams message from %s (age: %s)", msg.DisplayName, time.Since(t).Round(time.Minute)) + continue + } + } + } + content := stripHTMLTags(msg.Content) if content == "" { continue @@ -812,6 +822,7 @@ type teamsMsg struct { From string DisplayName string Content string + ComposeTime string } func (c *M365Connector) fetchTeamsMessages(token, convID string) []teamsMsg { @@ -854,6 +865,7 @@ func (c *M365Connector) fetchTeamsMessages(token, convID string) []teamsMsg { From: m.From, DisplayName: m.IMDisplayName, Content: m.Content, + ComposeTime: m.ComposeTime, }) }