mirror of
https://github.com/golang/go
synced 2024-11-22 07:34:40 -07:00
misc/dashboard/codereview: record Message-ID of code review thread mails.
This will allow us to properly thread "R=..." mails at a later time. R=golang-dev, r CC=golang-dev https://golang.org/cl/6135053
This commit is contained in:
parent
5d331964e7
commit
1bdb788b2e
@ -45,8 +45,9 @@ type CL struct {
|
|||||||
LGTMs []string
|
LGTMs []string
|
||||||
|
|
||||||
// Mail information.
|
// Mail information.
|
||||||
Subject string `datastore:",noindex"`
|
Subject string `datastore:",noindex"`
|
||||||
Recipients []string `datastore:",noindex"`
|
Recipients []string `datastore:",noindex"`
|
||||||
|
LastMessageID string `datastore:",noindex"`
|
||||||
|
|
||||||
// These are person IDs (e.g. "rsc"); they may be empty
|
// These are person IDs (e.g. "rsc"); they may be empty
|
||||||
Author string
|
Author string
|
||||||
@ -193,6 +194,8 @@ func handleAssign(w http.ResponseWriter, r *http.Request) {
|
|||||||
Subject: cl.Subject + " (issue " + n + ")",
|
Subject: cl.Subject + " (issue " + n + ")",
|
||||||
Body: "R=" + rev + "\n\n(sent by gocodereview)",
|
Body: "R=" + rev + "\n\n(sent by gocodereview)",
|
||||||
}
|
}
|
||||||
|
// TODO(dsymonds): Use cl.LastMessageID as the In-Reply-To header
|
||||||
|
// when the appengine/mail package supports that.
|
||||||
sendMailLater.Call(c, msg)
|
sendMailLater.Call(c, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,7 +342,8 @@ func updateCL(c appengine.Context, n string) error {
|
|||||||
if err != nil && err != datastore.ErrNoSuchEntity {
|
if err != nil && err != datastore.ErrNoSuchEntity {
|
||||||
return err
|
return err
|
||||||
} else if err == nil {
|
} else if err == nil {
|
||||||
// Reviewer is the only field that needs preserving.
|
// LastMessageID and Reviewer need preserving.
|
||||||
|
cl.LastMessageID = ocl.LastMessageID
|
||||||
cl.Reviewer = ocl.Reviewer
|
cl.Reviewer = ocl.Reviewer
|
||||||
}
|
}
|
||||||
_, err = datastore.Put(c, key, cl)
|
_, err = datastore.Put(c, key, cl)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"appengine"
|
"appengine"
|
||||||
|
"appengine/datastore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -35,6 +36,23 @@ func handleMail(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Infof("Found issue %q", m[1])
|
c.Infof("Found issue %q", m[1])
|
||||||
|
|
||||||
|
// Track the MessageID.
|
||||||
|
key := datastore.NewKey(c, "CL", m[1], 0, nil)
|
||||||
|
err = datastore.RunInTransaction(c, func(c appengine.Context) error {
|
||||||
|
cl := new(CL)
|
||||||
|
err := datastore.Get(c, key, cl)
|
||||||
|
if err != nil && err != datastore.ErrNoSuchEntity {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cl.LastMessageID = msg.Header.Get("Message-ID")
|
||||||
|
_, err = datastore.Put(c, key, cl)
|
||||||
|
return err
|
||||||
|
}, nil)
|
||||||
|
if err != nil {
|
||||||
|
c.Errorf("datastore transaction failed: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Update the CL after a delay to give Rietveld a chance to catch up.
|
// Update the CL after a delay to give Rietveld a chance to catch up.
|
||||||
UpdateCLLater(c, m[1], 10*time.Second)
|
UpdateCLLater(c, m[1], 10*time.Second)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user