Commit e5335101 authored by David Symonds's avatar David Symonds

misc/dashboard/codereview: switch to using gobot to update CL reviewer info.

R=rsc
CC=golang-dev
https://golang.org/cl/6453063
parent 41688046
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
netmail "net/mail"
"net/url" "net/url"
"regexp" "regexp"
"sort" "sort"
...@@ -23,7 +22,6 @@ import ( ...@@ -23,7 +22,6 @@ import (
"appengine" "appengine"
"appengine/datastore" "appengine/datastore"
"appengine/mail"
"appengine/taskqueue" "appengine/taskqueue"
"appengine/urlfetch" "appengine/urlfetch"
"appengine/user" "appengine/user"
...@@ -35,6 +33,7 @@ func init() { ...@@ -35,6 +33,7 @@ func init() {
} }
const codereviewBase = "http://codereview.appspot.com" const codereviewBase = "http://codereview.appspot.com"
const gobotBase = "http://research.swtch.com/gobot_codereview"
var clRegexp = regexp.MustCompile(`\d+`) var clRegexp = regexp.MustCompile(`\d+`)
...@@ -184,34 +183,21 @@ func handleAssign(w http.ResponseWriter, r *http.Request) { ...@@ -184,34 +183,21 @@ func handleAssign(w http.ResponseWriter, r *http.Request) {
if !found { if !found {
c.Infof("Adding %v as a reviewer of CL %v", rev, n) c.Infof("Adding %v as a reviewer of CL %v", rev, n)
// We can't do this easily, as we need authentication to edit url := fmt.Sprintf("%s?cl=%s&r=%s", gobotBase, n, rev)
// an issue on behalf of a user, which is non-trivial. For now, resp, err := urlfetch.Client(c).Get(url)
// just send a mail with the body "R=<reviewer>", Cc'ing that person,
// and rely on social convention.
cl := new(CL)
err := datastore.Get(c, key, cl)
if err != nil { if err != nil {
c.Errorf("%s", err) c.Errorf("Gobot GET failed: %v", err)
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
msg := &mail.Message{ defer resp.Body.Close()
Sender: u.Email, if resp.StatusCode != 200 {
To: []string{preferredEmail[rev]}, c.Errorf("Gobot GET failed: got HTTP response %d", resp.StatusCode)
Cc: cl.Recipients, http.Error(w, "Failed contacting Gobot", 500)
// Take care to match Rietveld's subject line return
// so that Gmail will correctly thread mail.
Subject: cl.Subject + " (issue " + n + ")",
Body: "R=" + rev + "\n\n(sent by gocodereview)",
}
if cl.LastMessageID != "" {
msg.Headers = netmail.Header{
"In-Reply-To": []string{cl.LastMessageID},
}
}
if err := mail.Send(c, msg); err != nil {
c.Errorf("mail.Send: %v", err)
} }
c.Infof("Gobot said %q", resp.Status)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment