Description []byte `datastore:",noindex"`
FirstLine string `datastore:",noindex"`
LGTMs []string
+ NotLGTMs []string
// Mail information.
Subject string `datastore:",noindex"`
return template.HTML(s)
}
-func (cl *CL) LGTMHTML() template.HTML {
- x := make([]string, len(cl.LGTMs))
- for i, s := range cl.LGTMs {
+func formatEmails(e []string) template.HTML {
+ x := make([]string, len(e))
+ for i, s := range e {
s = template.HTMLEscapeString(s)
if !strings.Contains(s, "@") {
s = "<b>" + s + "</b>"
return template.HTML(strings.Join(x, ", "))
}
+func (cl *CL) LGTMHTML() template.HTML {
+ return formatEmails(cl.LGTMs)
+}
+
+func (cl *CL) NotLGTMHTML() template.HTML {
+ return formatEmails(cl.NotLGTMs)
+}
+
func (cl *CL) ModifiedAgo() string {
// Just the first non-zero unit.
units := [...]struct {
cl.FirstLine = cl.FirstLine[:i]
}
lgtm := make(map[string]bool)
+ notLGTM := make(map[string]bool)
rcpt := make(map[string]bool)
for _, msg := range apiResp.Messages {
s, rev := msg.Sender, false
if msg.Approval {
lgtm[s] = true
+ delete(notLGTM, s) // "LGTM" overrules previous "NOT LGTM"
+ }
+ if strings.Contains(msg.Text, "NOT LGTM") {
+ notLGTM[s] = true
+ delete(lgtm, s) // "NOT LGTM" overrules previous "LGTM"
}
for _, r := range msg.Recipients {
for l := range lgtm {
cl.LGTMs = append(cl.LGTMs, l)
}
+ for l := range notLGTM {
+ cl.NotLGTMs = append(cl.NotLGTMs, l)
+ }
for r := range rcpt {
cl.Recipients = append(cl.Recipients, r)
}
sort.Strings(cl.LGTMs)
+ sort.Strings(cl.NotLGTMs)
sort.Strings(cl.Recipients)
err = datastore.RunInTransaction(c, func(c appengine.Context) error {