Suppress Fully alerts for silent senders (win alerts, loss alerts, instrumentation, salesforce)
This commit is contained in:
parent
a76f3677b4
commit
b408ebc2b7
|
|
@ -589,10 +589,29 @@ func (c *M365Connector) pollEmail() bool {
|
||||||
seenSet[id] = true
|
seenSet[id] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Senders whose emails are silently tracked (marked seen) but never posted to Fully dashboard.
|
||||||
|
silentSenders := []string{
|
||||||
|
"winalert@kaseya.com",
|
||||||
|
"lostalert@kaseya.com",
|
||||||
|
"standard.instrumentation@kaseya.com",
|
||||||
|
"noreply@salesforce.com",
|
||||||
|
}
|
||||||
|
isSilent := func(addr string) bool {
|
||||||
|
addr = strings.ToLower(strings.TrimSpace(addr))
|
||||||
|
for _, s := range silentSenders {
|
||||||
|
if addr == s {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
type emailDetail struct {
|
type emailDetail struct {
|
||||||
From string `json:"from"`
|
From string `json:"from"`
|
||||||
|
Address string `json:"address"`
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
BodyPreview string `json:"bodyPreview"`
|
BodyPreview string `json:"bodyPreview"`
|
||||||
|
Silent bool `json:"silent"`
|
||||||
}
|
}
|
||||||
var newEmails []string
|
var newEmails []string
|
||||||
var summaries []string
|
var summaries []string
|
||||||
|
|
@ -600,15 +619,18 @@ func (c *M365Connector) pollEmail() bool {
|
||||||
for _, msg := range result.Value {
|
for _, msg := range result.Value {
|
||||||
if !seenSet[msg.ID] {
|
if !seenSet[msg.ID] {
|
||||||
newEmails = append(newEmails, msg.ID)
|
newEmails = append(newEmails, msg.ID)
|
||||||
|
addr := strings.ToLower(strings.TrimSpace(msg.From.EmailAddress.Address))
|
||||||
from := msg.From.EmailAddress.Name
|
from := msg.From.EmailAddress.Name
|
||||||
if from == "" {
|
if from == "" {
|
||||||
from = msg.From.EmailAddress.Address
|
from = addr
|
||||||
}
|
}
|
||||||
summaries = append(summaries, fmt.Sprintf("%s: %s", from, msg.Subject))
|
summaries = append(summaries, fmt.Sprintf("%s: %s", from, msg.Subject))
|
||||||
details = append(details, emailDetail{
|
details = append(details, emailDetail{
|
||||||
From: from,
|
From: from,
|
||||||
|
Address: addr,
|
||||||
Subject: msg.Subject,
|
Subject: msg.Subject,
|
||||||
BodyPreview: truncateStr(msg.BodyPreview, 200),
|
BodyPreview: truncateStr(msg.BodyPreview, 200),
|
||||||
|
Silent: isSilent(addr),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -643,8 +665,13 @@ func (c *M365Connector) pollEmail() bool {
|
||||||
summary := fmt.Sprintf("%d new unread email(s): %s", len(newEmails), strings.Join(summaries, "; "))
|
summary := fmt.Sprintf("%d new unread email(s): %s", len(newEmails), strings.Join(summaries, "; "))
|
||||||
log.Printf("[m365] %s", summary)
|
log.Printf("[m365] %s", summary)
|
||||||
c.sendM365WebhookRich("email", summary, details)
|
c.sendM365WebhookRich("email", summary, details)
|
||||||
// Post AI-summarized alerts to Fully per email; track alert IDs for auto-removal
|
// Post AI-summarized alerts to Fully per email; track alert IDs for auto-removal.
|
||||||
|
// Silent senders (noise/automated) are skipped — tracked as seen but never shown on tablet.
|
||||||
for i, d := range details {
|
for i, d := range details {
|
||||||
|
if d.Silent {
|
||||||
|
log.Printf("[m365] Suppressing Fully alert for silent sender: %s", d.Address)
|
||||||
|
continue
|
||||||
|
}
|
||||||
msg := summarizeM365("📧", d.From, d.Subject, d.BodyPreview)
|
msg := summarizeM365("📧", d.From, d.Subject, d.BodyPreview)
|
||||||
alertID := postFullyAlert(msg, "info", "email:"+d.From)
|
alertID := postFullyAlert(msg, "info", "email:"+d.From)
|
||||||
if alertID != "" && i < len(newEmails) {
|
if alertID != "" && i < len(newEmails) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue