Skip to content

Commit 559fec5

Browse files
committed
repo_hook: add IssuesPayload
1 parent 264a3d5 commit 559fec5

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

gogs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func Version() string {
17-
return "0.12.7"
17+
return "0.12.8"
1818
}
1919

2020
// Client represents a Gogs API client.

repo_hook.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ const (
239239
HOOK_ISSUE_UNASSIGNED HookIssueAction = "unassigned"
240240
HOOK_ISSUE_LABEL_UPDATED HookIssueAction = "label_updated"
241241
HOOK_ISSUE_LABEL_CLEARED HookIssueAction = "label_cleared"
242+
HOOK_ISSUE_MILESTONED HookIssueAction = "milestoned"
243+
HOOK_ISSUE_DEMILESTONED HookIssueAction = "demilestoned"
242244
HOOK_ISSUE_SYNCHRONIZED HookIssueAction = "synchronized"
243245
)
244246

@@ -251,6 +253,19 @@ type ChangesPayload struct {
251253
Body *ChangesFromPayload `json:"body,omitempty"`
252254
}
253255

256+
type IssuesPayload struct {
257+
Action HookIssueAction `json:"action"`
258+
Index int64 `json:"number"`
259+
Issue *Issue `json:"issue"`
260+
Changes *ChangesPayload `json:"changes,omitempty"`
261+
Repository *Repository `json:"repository"`
262+
Sender *User `json:"sender"`
263+
}
264+
265+
func (p *IssuesPayload) JSONPayload() ([]byte, error) {
266+
return json.MarshalIndent(p, "", " ")
267+
}
268+
254269
// __________ .__ .__ __________ __
255270
// \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
256271
// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
@@ -262,8 +277,8 @@ type ChangesPayload struct {
262277
type PullRequestPayload struct {
263278
Action HookIssueAction `json:"action"`
264279
Index int64 `json:"number"`
265-
Changes *ChangesPayload `json:"changes,omitempty"`
266280
PullRequest *PullRequest `json:"pull_request"`
281+
Changes *ChangesPayload `json:"changes,omitempty"`
267282
Repository *Repository `json:"repository"`
268283
Sender *User `json:"sender"`
269284
}

user.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ type User struct {
1818
AvatarUrl string `json:"avatar_url"`
1919
}
2020

21-
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
21+
// MarshalJSON implements the json.Marshaler interface for User
2222
func (u User) MarshalJSON() ([]byte, error) {
2323
// Re-declaring User to avoid recursion
2424
type shadow User
2525
return json.Marshal(struct {
2626
shadow
27+
// LEGACY [Gogs 1.0]: remove field(s) for backward compatibility
2728
CompatUserName string `json:"username"`
2829
}{shadow(u), u.UserName})
2930
}

0 commit comments

Comments
 (0)