From 6ddaf205add421609ab82777d9d45da8b09ceb46 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 24 Oct 2017 11:10:19 +0200 Subject: dashboard/app: email fixes 1. Allows sending emails upstream. 2. Filter out duplicate emails coming from our mailing lists. 3. Increase retry attempts for email commands (don't want them to fail due to concurrent crash reports from managers). --- pkg/email/parser.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pkg/email/parser.go') diff --git a/pkg/email/parser.go b/pkg/email/parser.go index 56579157f..c000625b5 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -150,6 +150,21 @@ func RemoveAddrContext(email string) (string, string, error) { return addr.String(), context, nil } +func CanonicalEmail(email string) string { + addr, err := mail.ParseAddress(email) + if err != nil { + return email + } + at := strings.IndexByte(addr.Address, '@') + if at == -1 { + return email + } + if plus := strings.IndexByte(addr.Address[:at], '+'); plus != -1 { + addr.Address = addr.Address[:plus] + addr.Address[at:] + } + return strings.ToLower(addr.Address) +} + // extractCommand extracts command to syzbot from email body. // Commands are of the following form: // ^#syz cmd args... -- cgit mrf-deployment