shorten email actions to include just the first @ part

This commit is contained in:
lone-cloud 2026-04-15 09:48:07 -07:00
parent 3f8fc957c5
commit 960b5c2874
Signed by: lone-cloud
GPG key ID: B0848536D672CD8D

View file

@ -3,6 +3,7 @@ package delivery
import ( import (
"fmt" "fmt"
"regexp" "regexp"
"strings"
) )
var phoneRegex = regexp.MustCompile(`(?:\+?1[\s.-]?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}`) var phoneRegex = regexp.MustCompile(`(?:\+?1[\s.-]?)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}`)
@ -32,9 +33,13 @@ func enrichActions(notif Notification) Notification {
continue continue
} }
seen[addr] = true seen[addr] = true
local := addr
if i := strings.Index(addr, "@"); i != -1 {
local = addr[:i]
}
notif.Actions = append(notif.Actions, Action{ notif.Actions = append(notif.Actions, Action{
ID: fmt.Sprintf("email-%s", addr), ID: fmt.Sprintf("email-%s", addr),
Label: fmt.Sprintf("Email %s", addr), Label: fmt.Sprintf("Email %s", local),
Endpoint: fmt.Sprintf("mailto:%s", addr), Endpoint: fmt.Sprintf("mailto:%s", addr),
}) })
} }