fix: skip Teams messages older than 24h to prevent old channel messages surfacing

This commit is contained in:
James 2026-02-18 00:56:04 -05:00
parent 8d8a1516bd
commit b69af43840
1 changed files with 12 additions and 0 deletions

View File

@ -754,6 +754,16 @@ func (c *M365Connector) pollTeams() bool {
continue 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) content := stripHTMLTags(msg.Content)
if content == "" { if content == "" {
continue continue
@ -812,6 +822,7 @@ type teamsMsg struct {
From string From string
DisplayName string DisplayName string
Content string Content string
ComposeTime string
} }
func (c *M365Connector) fetchTeamsMessages(token, convID string) []teamsMsg { func (c *M365Connector) fetchTeamsMessages(token, convID string) []teamsMsg {
@ -854,6 +865,7 @@ func (c *M365Connector) fetchTeamsMessages(token, convID string) []teamsMsg {
From: m.From, From: m.From,
DisplayName: m.IMDisplayName, DisplayName: m.IMDisplayName,
Content: m.Content, Content: m.Content,
ComposeTime: m.ComposeTime,
}) })
} }