|
| 1 | +package structs |
| 2 | + |
| 3 | +import "code.gitea.io/gitea/modules/json" |
| 4 | + |
| 5 | +var ( |
| 6 | + _ Payloader = &IssuePayload{} |
| 7 | + _ Payloader = &IssueCommentPayload{} |
| 8 | +) |
| 9 | + |
| 10 | +// .___ |
| 11 | +// | | ______ ________ __ ____ |
| 12 | +// | |/ ___// ___/ | \_/ __ \ |
| 13 | +// | |\___ \ \___ \| | /\ ___/ |
| 14 | +// |___/____ >____ >____/ \___ > |
| 15 | +// \/ \/ \/ |
| 16 | + |
| 17 | +// HookIssueAction FIXME |
| 18 | +type HookIssueAction string |
| 19 | + |
| 20 | +const ( |
| 21 | + // HookIssueOpened opened |
| 22 | + HookIssueOpened HookIssueAction = "opened" |
| 23 | + // HookIssueClosed closed |
| 24 | + HookIssueClosed HookIssueAction = "closed" |
| 25 | + // HookIssueReOpened reopened |
| 26 | + HookIssueReOpened HookIssueAction = "reopened" |
| 27 | + // HookIssueEdited edited |
| 28 | + HookIssueEdited HookIssueAction = "edited" |
| 29 | + // HookIssueAssigned assigned |
| 30 | + HookIssueAssigned HookIssueAction = "assigned" |
| 31 | + // HookIssueUnassigned unassigned |
| 32 | + HookIssueUnassigned HookIssueAction = "unassigned" |
| 33 | + // HookIssueLabelUpdated label_updated |
| 34 | + HookIssueLabelUpdated HookIssueAction = "label_updated" |
| 35 | + // HookIssueLabelCleared label_cleared |
| 36 | + HookIssueLabelCleared HookIssueAction = "label_cleared" |
| 37 | + // HookIssueSynchronized synchronized |
| 38 | + HookIssueSynchronized HookIssueAction = "synchronized" |
| 39 | + // HookIssueMilestoned is an issue action for when a milestone is set on an issue. |
| 40 | + HookIssueMilestoned HookIssueAction = "milestoned" |
| 41 | + // HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue. |
| 42 | + HookIssueDemilestoned HookIssueAction = "demilestoned" |
| 43 | + // HookIssueReviewed is an issue action for when a pull request is reviewed |
| 44 | + HookIssueReviewed HookIssueAction = "reviewed" |
| 45 | + // HookIssueReviewRequested is an issue action for when a reviewer is requested for a pull request. |
| 46 | + HookIssueReviewRequested HookIssueAction = "review_requested" |
| 47 | + // HookIssueReviewRequestRemoved is an issue action for removing a review request to someone on a pull request. |
| 48 | + HookIssueReviewRequestRemoved HookIssueAction = "review_request_removed" |
| 49 | +) |
| 50 | + |
| 51 | +// IssuePayload represents the payload information that is sent along with an issue event. |
| 52 | +type IssuePayload struct { |
| 53 | + Action HookIssueAction `json:"action"` |
| 54 | + Index int64 `json:"number"` |
| 55 | + Changes *ChangesPayload `json:"changes,omitempty"` |
| 56 | + Issue *Issue `json:"issue"` |
| 57 | + Repository *Repository `json:"repository"` |
| 58 | + Sender *User `json:"sender"` |
| 59 | + CommitID string `json:"commit_id"` |
| 60 | +} |
| 61 | + |
| 62 | +// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces. |
| 63 | +func (p *IssuePayload) JSONPayload() ([]byte, error) { |
| 64 | + return json.MarshalIndent(p, "", " ") |
| 65 | +} |
| 66 | + |
| 67 | +// HookIssueCommentAction defines hook issue comment action |
| 68 | +type HookIssueCommentAction string |
| 69 | + |
| 70 | +// all issue comment actions |
| 71 | +const ( |
| 72 | + HookIssueCommentCreated HookIssueCommentAction = "created" |
| 73 | + HookIssueCommentEdited HookIssueCommentAction = "edited" |
| 74 | + HookIssueCommentDeleted HookIssueCommentAction = "deleted" |
| 75 | +) |
| 76 | + |
| 77 | +// IssueCommentPayload represents a payload information of issue comment event. |
| 78 | +type IssueCommentPayload struct { |
| 79 | + Action HookIssueCommentAction `json:"action"` |
| 80 | + Issue *Issue `json:"issue"` |
| 81 | + Comment *Comment `json:"comment"` |
| 82 | + Changes *ChangesPayload `json:"changes,omitempty"` |
| 83 | + Repository *Repository `json:"repository"` |
| 84 | + Sender *User `json:"sender"` |
| 85 | + IsPull bool `json:"is_pull"` |
| 86 | +} |
| 87 | + |
| 88 | +// JSONPayload implements Payload |
| 89 | +func (p *IssueCommentPayload) JSONPayload() ([]byte, error) { |
| 90 | + return json.MarshalIndent(p, "", " ") |
| 91 | +} |
| 92 | + |
| 93 | +// ChangesFromPayload FIXME |
| 94 | +type ChangesFromPayload struct { |
| 95 | + From string `json:"from"` |
| 96 | +} |
| 97 | + |
| 98 | +// ChangesPayload represents the payload information of issue change |
| 99 | +type ChangesPayload struct { |
| 100 | + Title *ChangesFromPayload `json:"title,omitempty"` |
| 101 | + Body *ChangesFromPayload `json:"body,omitempty"` |
| 102 | + Ref *ChangesFromPayload `json:"ref,omitempty"` |
| 103 | +} |
0 commit comments