mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Display names instead of emails in OpsGenie widget
This commit is contained in:
parent
5c9da163b2
commit
8c856477e1
@ -17,13 +17,6 @@ type OnCallResponse struct {
|
||||
type OnCallData struct {
|
||||
Recipients []string `json:"onCallRecipients"`
|
||||
Parent Parent `json:"_parent"`
|
||||
Users []OnCallUserData
|
||||
}
|
||||
|
||||
type OnCallUserData struct {
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
FullName string `json:"fullName"`
|
||||
}
|
||||
|
||||
type Parent struct {
|
||||
|
@ -61,9 +61,20 @@ func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string {
|
||||
|
||||
for _, data := range onCallResponse.OnCallData {
|
||||
str = str + fmt.Sprintf(" [green]%s[white]\n", data.Parent.Name)
|
||||
str = str + fmt.Sprintf(" %s\n", strings.Join(data.Recipients, ", "))
|
||||
str = str + fmt.Sprintf(" %s\n", strings.Join(widget.namesFromEmails(data.Recipients), ", "))
|
||||
str = str + "\n"
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
func (widget *Widget) namesFromEmails(emails []string) []string {
|
||||
names := []string{}
|
||||
|
||||
for _, email := range emails {
|
||||
parts := strings.Split(email, "@")
|
||||
names = append(names, strings.Title(strings.Replace(parts[0], ".", " ", -1)))
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user