Reexport gitea types as local types

This commit is contained in:
2022-12-24 15:11:47 -07:00
parent 1c899982c1
commit a2bdbf1756
+22 -11
View File
@@ -50,6 +50,17 @@ const (
PackageEvent Event = "package" PackageEvent Event = "package"
) )
type CreatePayload structs.CreatePayload
type DeletePayload structs.DeletePayload
type ForkPayload structs.ForkPayload
type IssuePayload structs.IssuePayload
type IssueCommentPayload structs.IssueCommentPayload
type PushPayload structs.PushPayload
type PullRequestPayload structs.PullRequestPayload
type RepositoryPayload structs.RepositoryPayload
type ReleasePayload structs.ReleasePayload
type PackagePayload structs.PackagePayload
// EventSubtype defines a GitHub Hook Event subtype // EventSubtype defines a GitHub Hook Event subtype
type EventSubtype string type EventSubtype string
@@ -149,48 +160,48 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
switch giteaEvent { switch giteaEvent {
case CreateEvent: case CreateEvent:
var pl structs.CreatePayload var pl CreatePayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case DeleteEvent: case DeleteEvent:
var pl structs.DeletePayload var pl DeletePayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case ForkEvent: case ForkEvent:
var pl structs.ForkPayload var pl ForkPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case IssuesEvent, IssueAssignEvent, IssueLabelEvent, IssueMilestoneEvent: case IssuesEvent, IssueAssignEvent, IssueLabelEvent, IssueMilestoneEvent:
var pl structs.IssuePayload var pl IssuePayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case IssueCommentEvent, PullRequestCommentEvent: case IssueCommentEvent, PullRequestCommentEvent:
var pl structs.IssueCommentPayload var pl IssueCommentPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case PushEvent: case PushEvent:
var pl structs.PushPayload var pl PushPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case PullRequestEvent, PullRequestAssignEvent, PullRequestLabelEvent, case PullRequestEvent, PullRequestAssignEvent, PullRequestLabelEvent,
PullRequestMilestoneEvent, PullRequestSyncEvent: PullRequestMilestoneEvent, PullRequestSyncEvent:
var pl structs.PullRequestPayload var pl PullRequestPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case PullRequestReviewEvent: case PullRequestReviewEvent:
var pl structs.PullRequestPayload var pl PullRequestPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case RepositoryEvent: case RepositoryEvent:
var pl structs.RepositoryPayload var pl RepositoryPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case ReleaseEvent: case ReleaseEvent:
var pl structs.ReleasePayload var pl ReleasePayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
case PackageEvent: case PackageEvent:
var pl structs.PackagePayload var pl PackagePayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
return pl, err return pl, err
default: default: