-
Notifications
You must be signed in to change notification settings - Fork 6
/
payload.go
186 lines (141 loc) · 4.98 KB
/
payload.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package jira_hooks
import (
"github.com/trifonovmixail/jira-hooks/objects"
"strings"
)
// Transitions
func isTransitionIssueStatusPayload(payload []byte) bool {
data := string(payload)
hasTransition := strings.Contains(data, "\"transition\"")
hasFromStatus := strings.Contains(data, "\"from_status\"")
hasToStatus := strings.Contains(data, "\"to_status\"")
return hasTransition && hasFromStatus && hasToStatus
}
type TransitionIssueStatusPayload struct {
Time objects.Timestamp `json:"timestamp"`
User *objects.User `json:"user"`
Issue *objects.Issue `json:"issue"`
Transition *objects.StatusTransition `json:"transition"`
}
func (s *TransitionIssueStatusPayload) isEmpty() bool {
hasWorkFlow := s.Transition.WorkFlowID != 0
hasTransition := s.Transition.TransitionID != 0
return !(hasWorkFlow && hasTransition)
}
// Issues
type issuePayload struct {
Time objects.Timestamp `json:"timestamp"`
User *objects.User `json:"user"`
Issue *objects.Issue `json:"issue"`
}
type issueUpdatedPayload struct {
Time objects.Timestamp `json:"timestamp"`
User *objects.User `json:"user"`
Issue *objects.Issue `json:"issue"`
ChangeLog *objects.ChangeLog `json:"changelog"`
Comment *objects.Comment `json:"comment"`
}
type issueCommentPayload struct {
Time objects.Timestamp `json:"timestamp"`
User *objects.User `json:"user"`
Issue *objects.Issue `json:"issue"`
Comment *objects.Comment `json:"comment"`
}
type IssueCreatedPayload issuePayload
type IssueDeletedPayload issuePayload
type IssueGenericPayload issueUpdatedPayload
type IssueUpdatedPayload issueUpdatedPayload
type IssueAssignedPayload issueUpdatedPayload
type IssueCommentCreatedPayload issueCommentPayload
type IssueCommentUpdatedPayload issueCommentPayload
type IssueCommentDeletedPayload issuePayload
type IssueWorkLogCreatedPayload issueUpdatedPayload
type IssueWorkLogUpdatedPayload issueUpdatedPayload
type IssueWorkLogDeletedPayload issueUpdatedPayload
type IssueMovedPayload issueUpdatedPayload
type IssueClosedPayload issueUpdatedPayload
// WorkLogs
type workLogPayload struct {
Time objects.Timestamp `json:"timestamp"`
WorkLog *objects.WorkLogRecord `json:"worklog"`
}
type WorkLogCreatedPayload workLogPayload
type WorkLogUpdatedPayload workLogPayload
type WorkLogDeletedPayload workLogPayload
// Comments
type commentPayload struct {
Time objects.Timestamp `json:"timestamp"`
Comment *objects.Comment `json:"comment"`
}
type CommentCreatedPayload commentPayload
type CommentUpdatedPayload commentPayload
type CommentDeletedPayload commentPayload
// Links
type linkPayload struct {
Time objects.Timestamp `json:"timestamp"`
Link *objects.LinkPayloadLink `json:"issueLink"`
}
type LinkCreatedPayload linkPayload
type LinkDeletedPayload linkPayload
// Users
type userPayload struct {
Time objects.Timestamp `json:"timestamp"`
User *objects.User `json:"user"`
}
type UserCreatedPayload userPayload
type UserUpdatedPayload userPayload
type UserDeletedPayload userPayload
// Projects
type projectPayload struct {
Time objects.Timestamp `json:"timestamp"`
Project *objects.Project `json:"project"`
}
type ProjectCreatedPayload projectPayload
type ProjectUpdatedPayload projectPayload
type ProjectDeletedPayload projectPayload
type ProjectArchivedPayload projectPayload
type ProjectRestoredPayload projectPayload
// Boards
type BoardConfigurationChangedPayload struct {
Time objects.Timestamp `json:"timestamp"`
Configuration *objects.BoardConfiguration `json:"configuration"`
}
type boardPayload struct {
Time objects.Timestamp `json:"timestamp"`
Board *objects.Board `json:"board"`
}
type BoardCreatedPayload boardPayload
type BoardUpdatedPayload boardPayload
type BoardDeletedPayload boardPayload
// Sprints
type sprintPayload struct {
Time objects.Timestamp `json:"timestamp"`
Sprint *objects.Sprint `json:"sprint"`
}
type SprintCreatedPayload sprintPayload
type SprintUpdatedPayload sprintPayload
type SprintDeletedPayload sprintPayload
type SprintStartedPayload sprintPayload
type SprintClosedPayload sprintPayload
// Versions
type versionPayload struct {
Time objects.Timestamp `json:"timestamp"`
Version *objects.Version `json:"version"`
}
type VersionCreatedPayload versionPayload
type VersionUpdatedPayload versionPayload
type VersionDeletedPayload versionPayload
type VersionReleasedPayload versionPayload
type VersionUnreleasedPayload versionPayload
// Options
type optionChangedPayload struct {
Time objects.Timestamp `json:"timestamp"`
Property *objects.Property `json:"property"`
}
type OptionTimeTrackingChangedPayload optionChangedPayload
type OptionIssueLinksChangedPayload optionChangedPayload
type OptionSubTasksChangedPayload optionChangedPayload
type OptionAttachmentsChangedPayload optionChangedPayload
type OptionWatchingChangedPayload optionChangedPayload
type OptionVotingChangedPayload optionChangedPayload
type OptionUnassignedIssuesChangedPayload optionChangedPayload