aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/dashapi/dashapi.go
diff options
context:
space:
mode:
authorPedro Lopes <pedrolopes@google.com>2020-07-28 15:52:55 -0500
committerDmitry Vyukov <dvyukov@google.com>2020-07-31 17:18:29 +0200
commit68aca71e8de884b64dc78a5d5406ca232460c1cf (patch)
treed0b3a0076be21f47a549c2654ccb3ee0452383d7 /dashboard/dashapi/dashapi.go
parent8df85ed9883abc2a200858f44f22c11c602d218a (diff)
dashboard/dashapi: create Recipients
Create struct Recipients to store a slice structs (RecipientInfo) of email, default name, and if the user should be added to To or Cc when sending the email. After this commit Commit::Cc and Crash::Maintainers will become deprecated.
Diffstat (limited to 'dashboard/dashapi/dashapi.go')
-rw-r--r--dashboard/dashapi/dashapi.go45
1 files changed, 36 insertions, 9 deletions
diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go
index e760a5ab5..2c2a993ea 100644
--- a/dashboard/dashapi/dashapi.go
+++ b/dashboard/dashapi/dashapi.go
@@ -13,6 +13,7 @@ import (
"io"
"io/ioutil"
"net/http"
+ "net/mail"
"net/url"
"reflect"
"strings"
@@ -77,7 +78,8 @@ type Commit struct {
Title string
Author string
AuthorName string
- CC []string
+ CC []string // deprecated in favor of Recipients
+ Recipients Recipients
BugIDs []string // ID's extracted from Reported-by tags
Date time.Time
}
@@ -234,8 +236,9 @@ func (dash *Dashboard) UploadCommits(commits []Commit) error {
type Crash struct {
BuildID string // refers to Build.ID
Title string
- Corrupted bool // report is corrupted (corrupted title, no stacks, etc)
- Maintainers []string
+ Corrupted bool // report is corrupted (corrupted title, no stacks, etc)
+ Maintainers []string // deprecated in favor of Recipients
+ Recipients Recipients
Log []byte
Report []byte
// The following is optional and is filled only after repro.
@@ -304,10 +307,11 @@ type BugReport struct {
Moderation bool
NoRepro bool // We don't expect repro (e.g. for build/boot errors).
Title string
- Link string // link to the bug on dashboard
- CreditEmail string // email for the Reported-by tag
- Maintainers []string
- CC []string // additional CC emails
+ Link string // link to the bug on dashboard
+ CreditEmail string // email for the Reported-by tag
+ Maintainers []string // deprecated in favor of Recipients
+ CC []string // deprecated in favor of Recipients
+ Recipients Recipients
OS string
Arch string
VMArch string
@@ -391,8 +395,9 @@ type BugNotification struct {
ExtID string // arbitrary reporting ID forwarded from BugUpdate.ExtID
Title string
Text string // meaning depends on Type
- CC []string // additional CC emails
- Maintainers []string
+ CC []string // deprecated in favor of Recipients
+ Maintainers []string // deprecated in favor of Recipients
+ Recipients Recipients
// Public is what we want all involved people to see (e.g. if we notify about a wrong commit title,
// people need to see it and provide the right title). Not public is what we want to send only
// to a minimal set of recipients (our mailing list) (e.g. notification about an obsoleted bug
@@ -623,3 +628,25 @@ func (dash *Dashboard) queryImpl(method string, req, reply interface{}) error {
}
return nil
}
+
+type RecipientType int
+
+const (
+ To RecipientType = iota
+ Cc
+)
+
+func (t RecipientType) String() string {
+ return [...]string{"To", "Cc"}[t]
+}
+
+type RecipientInfo struct {
+ Address mail.Address
+ Type RecipientType
+}
+
+type Recipients []RecipientInfo
+
+func (r Recipients) Len() int { return len(r) }
+func (r Recipients) Less(i, j int) bool { return r[i].Address.Address < r[j].Address.Address }
+func (r Recipients) Swap(i, j int) { r[i], r[j] = r[j], r[i] }