all repos — navani @ b9e318987ea1da4422e9d5e1ce0bf72ee361a93d

forlater's primary mail processing service

Strip sigs when body is whole
Anirudh Oppiliappan x@icyphox.sh
Fri, 01 Oct 2021 17:58:54 +0530
commit

b9e318987ea1da4422e9d5e1ce0bf72ee361a93d

parent

efd12d0e25b5a597b98dc3faef990157e10dfb20

2 files changed, 3 insertions(+), 3 deletions(-)

jump to
M mail/utils.gomail/utils.go

@@ -18,7 +18,7 @@ }

// TODO // Strips the signature from an email. -func stripSignature(text string) string { +func StripSignature(text string) string { lines := strings.Split(text, "\n") body := []string{} for i := range lines {

@@ -39,7 +39,7 @@

// Returns the main body of the email; hopefully containing URLs. func MailBody(parts map[string]string) (string, error) { if plain, ok := parts["text/plain"]; ok { - return stripSignature(plain), nil + return StripSignature(plain), nil } else if html, ok := parts["text/html"]; ok { p := bluemonday.NewPolicy() p.AllowStandardURLs()
M main.gomain.go

@@ -18,7 +18,7 @@ body, err := mail.MailBody(m.Parts)

log.Printf("recieved webhook: %v\n", m.From) if err != nil { log.Printf("using body as is: %v\n", err) - body = m.Body + body = mail.StripSignature(m.Body) } urls := mail.ExtractURLs(body)