dashboard/add: don't log bad emails as errors

This commit is contained in:
Dmitry Vyukov 2018-03-20 11:55:55 +01:00
parent b389d9170c
commit 72c33b66ba

View File

@ -10,6 +10,7 @@ import (
"io/ioutil"
"net/http"
"net/mail"
"regexp"
"strings"
"text/template"
"time"
@ -349,15 +350,22 @@ func incomingMail(c context.Context, r *http.Request) error {
func handleEmailBounce(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
log.Errorf(c, "email bounced")
body, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Errorf(c, "failed to read body: %v", err)
log.Errorf(c, "email bounced: failed to read body: %v", err)
return
}
if nonCriticalBounceRe.Match(body) {
log.Infof(c, "email bounced: address not found")
} else {
log.Errorf(c, "email bounced")
}
log.Infof(c, "%s", body)
}
// These are just stale emails in MAINTAINERS.
var nonCriticalBounceRe = regexp.MustCompile(`\*\* Address not found \*\*|550 #5\.1\.0 Address rejected`)
func loadBugInfo(c context.Context, msg *email.Email) (bug *Bug, bugReporting *BugReporting, reporting *Reporting) {
if msg.BugID == "" {
if msg.Command == "" {