Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit a391123

Browse files
ethantkoenigappleboy
authored andcommitted
Support for repo creation/deletion webhooks (#55)
1 parent e1c76d4 commit a391123

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

gitea/hook.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,39 @@ func (p *PullRequestPayload) SetSecret(secret string) {
353353
func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
354354
return json.MarshalIndent(p, "", " ")
355355
}
356+
357+
//__________ .__ __
358+
//\______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
359+
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
360+
// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
361+
// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
362+
// \/ \/|__| \/ \/
363+
364+
// HookRepoAction an action that happens to a repo
365+
type HookRepoAction string
366+
367+
const (
368+
// HookRepoCreated created
369+
HookRepoCreated HookRepoAction = "created"
370+
// HookRepoDeleted deleted
371+
HookRepoDeleted HookRepoAction = "deleted"
372+
)
373+
374+
// RepositoryPayload payload for repository webhooks
375+
type RepositoryPayload struct {
376+
Secret string `json:"secret"`
377+
Action HookRepoAction `json:"action"`
378+
Repository *Repository `json:"repository"`
379+
Organization *User `json:"organization"`
380+
Sender *User `json:"sender"`
381+
}
382+
383+
// SetSecret set the payload's secret
384+
func (p *RepositoryPayload) SetSecret(secret string) {
385+
p.Secret = secret
386+
}
387+
388+
// JSONPayload JSON representation of the payload
389+
func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
390+
return json.MarshalIndent(p, "", " ")
391+
}

0 commit comments

Comments
 (0)