forked from harness/harness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.go
71 lines (57 loc) · 1.34 KB
/
notification.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package notify
import (
"github.com/drone/drone/pkg/model"
)
// Context represents the context of an
// in-progress build request.
type Context struct {
// Global settings
Host string
// User that owns the repository
User *model.User
// Repository being built.
Repo *model.Repo
// Commit being built
Commit *model.Commit
}
type Sender interface {
Send(context *Context) error
}
// Notification stores the configuration details
// for notifying a user, or group of users,
// when their Build has completed.
type Notification struct {
Email *Email `yaml:"email,omitempty"`
Webhook *Webhook `yaml:"webhook,omitempty"`
Hipchat *Hipchat `yaml:"hipchat,omitempty"`
Irc *IRC `yaml:"irc,omitempty"`
Slack *Slack `yaml:"slack,omitempty"`
Flowdock *Flowdock `yaml:"flowdock,omitempty"`
}
func (n *Notification) Send(context *Context) error {
// send email notifications
if n.Email != nil {
n.Email.Send(context)
}
// send email notifications
if n.Webhook != nil {
n.Webhook.Send(context)
}
// send email notifications
if n.Hipchat != nil {
n.Hipchat.Send(context)
}
// send irc notifications
if n.Irc != nil {
n.Irc.Send(context)
}
// send slack notifications
if n.Slack != nil {
n.Slack.Send(context)
}
// send flowdock notifications
if n.Flowdock != nil {
n.Flowdock.Send(context)
}
return nil
}