-
Notifications
You must be signed in to change notification settings - Fork 8
/
events_user.go
128 lines (103 loc) · 3.27 KB
/
events_user.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package scalingo
import "fmt"
type EventNewIntegrationType struct {
Event
TypeData EventNewIntegrationTypeData `json:"type_data"`
}
func (ev *EventNewIntegrationType) String() string {
integrationType, ok := SCMTypeDisplay[ev.TypeData.IntegrationType]
if !ok {
integrationType = string(ev.TypeData.IntegrationType)
}
msg := integrationType
if ev.TypeData.IntegrationType == SCMGithubEnterpriseType ||
ev.TypeData.IntegrationType == SCMGitlabSelfHostedType {
msg = fmt.Sprintf("%s (%s)", msg, ev.TypeData.Data.URL)
}
return fmt.Sprintf("%s account '%s' has been authorized", msg, ev.TypeData.Data.Login)
}
type EventNewIntegrationTypeData struct {
IntegrationID string `json:"integration_id"`
IntegrationType SCMType `json:"integration_type"`
Data struct {
Login string `json:"login"`
AvatarURL string `json:"avatar_url"`
URL string `json:"url"`
} `json:"data"`
}
type EventDeleteIntegrationType struct {
Event
TypeData EventDeleteIntegrationTypeData `json:"type_data"`
}
func (ev *EventDeleteIntegrationType) String() string {
integrationType, ok := SCMTypeDisplay[ev.TypeData.IntegrationType]
if !ok {
integrationType = string(ev.TypeData.IntegrationType)
}
msg := integrationType
if ev.TypeData.IntegrationType == SCMGithubEnterpriseType ||
ev.TypeData.IntegrationType == SCMGitlabSelfHostedType {
msg = fmt.Sprintf("%s (%s)", msg, ev.TypeData.Data.URL)
}
return fmt.Sprintf("%s account '%s' has been revoked", msg, ev.TypeData.Data.Login)
}
type EventDeleteIntegrationTypeData struct {
IntegrationID string `json:"integration_id"`
IntegrationType SCMType `json:"integration_type"`
Data struct {
Login string `json:"login"`
AvatarURL string `json:"avatar_url"`
URL string `json:"url"`
} `json:"data"`
}
type EventAuthorizeGithubType struct {
Event
TypeData EventAuthorizeGithubTypeData `json:"type_data"`
}
func (ev *EventAuthorizeGithubType) String() string {
return fmt.Sprintf("GitHub account '%s' has been authorized", ev.TypeData.GithubUser.Login)
}
type EventAuthorizeGithubTypeData struct {
GithubUser struct {
Login string `json:"login"`
AvatarURL string `json:"avatar_url"`
} `json:"github_user"`
}
type EventRevokeGithubType struct {
Event
}
func (ev *EventRevokeGithubType) String() string {
return "GitHub authorization has been revoked"
}
type EventNewKeyTypeData struct {
Name string `json:"name"`
Fingerprint string `json:"fingerprint"`
}
type EventNewKeyType struct {
Event
TypeData EventNewKeyTypeData `json:"type_data"`
}
func (ev *EventNewKeyType) String() string {
return fmt.Sprintf("name '%s' with fingerprint %s", ev.TypeData.Name, ev.TypeData.Fingerprint)
}
type EventEditKeyTypeData struct {
Name string `json:"name"`
Fingerprint string `json:"fingerprint"`
}
type EventEditKeyType struct {
Event
TypeData EventEditKeyTypeData `json:"type_data"`
}
func (ev *EventEditKeyType) String() string {
return fmt.Sprintf("name '%s' with fingerprint %s updated", ev.TypeData.Name, ev.TypeData.Fingerprint)
}
type EventDeleteKeyTypeData struct {
Name string `json:"name"`
}
type EventDeleteKeyType struct {
Event
TypeData EventDeleteKeyTypeData `json:"type_data"`
}
func (ev *EventDeleteKeyType) String() string {
return fmt.Sprintf("name '%s'", ev.TypeData.Name)
}