|
1 | 1 | // Copyright 2014 The Gogs Authors. All rights reserved.
|
| 2 | +// Copyright 2017 The Gitea Authors. All rights reserved. |
2 | 3 | // Use of this source code is governed by a MIT-style
|
3 | 4 | // license that can be found in the LICENSE file.
|
4 | 5 |
|
@@ -147,6 +148,7 @@ type PayloadCommit struct {
|
147 | 148 | var (
|
148 | 149 | _ Payloader = &CreatePayload{}
|
149 | 150 | _ Payloader = &PushPayload{}
|
| 151 | + _ Payloader = &IssuePayload{} |
150 | 152 | _ Payloader = &PullRequestPayload{}
|
151 | 153 | )
|
152 | 154 |
|
@@ -277,8 +279,33 @@ const (
|
277 | 279 | HookIssueLabelCleared HookIssueAction = "label_cleared"
|
278 | 280 | // HookIssueSynchronized synchronized
|
279 | 281 | HookIssueSynchronized HookIssueAction = "synchronized"
|
| 282 | + // HookIssueMilestoned is an issue action for when a milestone is set on an issue. |
| 283 | + HookIssueMilestoned HookIssueAction = "milestoned" |
| 284 | + // HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue. |
| 285 | + HookIssueDemilestoned HookIssueAction = "demilestoned" |
280 | 286 | )
|
281 | 287 |
|
| 288 | +// IssuePayload represents the payload information that is sent along with an issue event. |
| 289 | +type IssuePayload struct { |
| 290 | + Secret string `json:"secret"` |
| 291 | + Action HookIssueAction `json:"action"` |
| 292 | + Index int64 `json:"number"` |
| 293 | + Changes *ChangesPayload `json:"changes,omitempty"` |
| 294 | + Issue *Issue `json:"issue"` |
| 295 | + Repository *Repository `json:"repository"` |
| 296 | + Sender *User `json:"sender"` |
| 297 | +} |
| 298 | + |
| 299 | +// SetSecret modifies the secret of the IssuePayload. |
| 300 | +func (p *IssuePayload) SetSecret(secret string) { |
| 301 | + p.Secret = secret |
| 302 | +} |
| 303 | + |
| 304 | +// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces. |
| 305 | +func (p *IssuePayload) JSONPayload() ([]byte, error) { |
| 306 | + return json.MarshalIndent(p, "", " ") |
| 307 | +} |
| 308 | + |
282 | 309 | // ChangesFromPayload FIXME
|
283 | 310 | type ChangesFromPayload struct {
|
284 | 311 | From string `json:"from"`
|
@@ -308,7 +335,7 @@ type PullRequestPayload struct {
|
308 | 335 | Sender *User `json:"sender"`
|
309 | 336 | }
|
310 | 337 |
|
311 |
| -// SetSecret FIXME |
| 338 | +// SetSecret modifies the secret of the PullRequestPayload. |
312 | 339 | func (p *PullRequestPayload) SetSecret(secret string) {
|
313 | 340 | p.Secret = secret
|
314 | 341 | }
|
|
0 commit comments