Documentation ¶
Index ¶
- Constants
- func CleanupHookTaskTable(ctx context.Context, cleanupType HookTaskCleanupType, olderThan time.Duration, ...) error
- func CopyDefaultWebhooksToRepo(ctx context.Context, repoID int64) error
- func CountWebhooksByOpts(opts *ListWebhookOptions) (int64, error)
- func CreateHookTask(t *HookTask) error
- func CreateWebhook(ctx context.Context, w *Webhook) error
- func DeleteDefaultSystemWebhook(id int64) error
- func DeleteWebhookByOrgID(orgID, id int64) error
- func DeleteWebhookByRepoID(repoID, id int64) error
- func IsErrHookTaskNotExist(err error) bool
- func IsErrWebhookNotExist(err error) bool
- func IsValidHookContentType(name string) bool
- func UpdateHookTask(t *HookTask) error
- func UpdateWebhook(w *Webhook) error
- func UpdateWebhookLastStatus(w *Webhook) error
- type ErrHookTaskNotExist
- type ErrWebhookNotExist
- type HookContentType
- type HookEvent
- type HookEventType
- type HookEvents
- type HookRequest
- type HookResponse
- type HookStatus
- type HookTask
- type HookTaskCleanupType
- type HookType
- type ListWebhookOptions
- type Webhook
- func GetDefaultWebhooks() ([]*Webhook, error)
- func GetSystemOrDefaultWebhook(id int64) (*Webhook, error)
- func GetSystemWebhooks(isActive util.OptionalBool) ([]*Webhook, error)
- func GetWebhookByID(id int64) (*Webhook, error)
- func GetWebhookByOrgID(orgID, id int64) (*Webhook, error)
- func GetWebhookByRepoID(repoID, id int64) (*Webhook, error)
- func ListWebhooksByOpts(opts *ListWebhookOptions) ([]*Webhook, error)
- func (w *Webhook) AfterLoad()
- func (w *Webhook) EventCheckers() []struct{ ... }
- func (w *Webhook) EventsArray() []string
- func (w *Webhook) HasCreateEvent() bool
- func (w *Webhook) HasDeleteEvent() bool
- func (w *Webhook) HasForkEvent() bool
- func (w *Webhook) HasIssueCommentEvent() bool
- func (w *Webhook) HasIssuesAssignEvent() bool
- func (w *Webhook) HasIssuesEvent() bool
- func (w *Webhook) HasIssuesLabelEvent() bool
- func (w *Webhook) HasIssuesMilestoneEvent() bool
- func (w *Webhook) HasPullRequestApprovedEvent() bool
- func (w *Webhook) HasPullRequestAssignEvent() bool
- func (w *Webhook) HasPullRequestCommentEvent() bool
- func (w *Webhook) HasPullRequestEvent() bool
- func (w *Webhook) HasPullRequestLabelEvent() bool
- func (w *Webhook) HasPullRequestMilestoneEvent() bool
- func (w *Webhook) HasPullRequestRejectedEvent() bool
- func (w *Webhook) HasPullRequestReviewCommentEvent() bool
- func (w *Webhook) HasPullRequestSyncEvent() bool
- func (w *Webhook) HasPushEvent() bool
- func (w *Webhook) HasReleaseEvent() bool
- func (w *Webhook) HasRepositoryEvent() bool
- func (w *Webhook) History(page int) ([]*HookTask, error)
- func (w *Webhook) UpdateEvent() error
Constants ¶
const ( HookStatusNone = iota HookStatusSucceed HookStatusFail )
Possible statuses of a web hook
Variables ¶
This section is empty.
Functions ¶
func CleanupHookTaskTable ¶
func CleanupHookTaskTable(ctx context.Context, cleanupType HookTaskCleanupType, olderThan time.Duration, numberToKeep int) error
CleanupHookTaskTable deletes rows from hook_task as needed.
func CopyDefaultWebhooksToRepo ¶
CopyDefaultWebhooksToRepo creates copies of the default webhooks in a new repo
func CountWebhooksByOpts ¶
func CountWebhooksByOpts(opts *ListWebhookOptions) (int64, error)
CountWebhooksByOpts count webhooks based on options and ignore pagination
func CreateHookTask ¶
CreateHookTask creates a new hook task, it handles conversion from Payload to PayloadContent.
func CreateWebhook ¶
CreateWebhook creates a new web hook.
func DeleteDefaultSystemWebhook ¶
DeleteDefaultSystemWebhook deletes an admin-configured default or system webhook (where Org and Repo ID both 0)
func DeleteWebhookByOrgID ¶
DeleteWebhookByOrgID deletes webhook of organization by given ID.
func DeleteWebhookByRepoID ¶
DeleteWebhookByRepoID deletes webhook of repository by given ID.
func IsErrHookTaskNotExist ¶
IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
func IsErrWebhookNotExist ¶
IsErrWebhookNotExist checks if an error is a ErrWebhookNotExist.
func IsValidHookContentType ¶
IsValidHookContentType returns true if given name is a valid hook content type.
func UpdateHookTask ¶
UpdateHookTask updates information of hook task.
func UpdateWebhook ¶
UpdateWebhook updates information of webhook.
func UpdateWebhookLastStatus ¶
UpdateWebhookLastStatus updates last status of webhook.
Types ¶
type ErrHookTaskNotExist ¶
ErrHookTaskNotExist represents a "HookTaskNotExist" kind of error.
func (ErrHookTaskNotExist) Error ¶
func (err ErrHookTaskNotExist) Error() string
type ErrWebhookNotExist ¶
type ErrWebhookNotExist struct {
ID int64
}
ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
func (ErrWebhookNotExist) Error ¶
func (err ErrWebhookNotExist) Error() string
type HookContentType ¶
type HookContentType int
HookContentType is the content type of a web hook
const ( // ContentTypeJSON is a JSON payload for web hooks ContentTypeJSON HookContentType = iota + 1 // ContentTypeForm is an url-encoded form payload for web hook ContentTypeForm )
func ToHookContentType ¶
func ToHookContentType(name string) HookContentType
ToHookContentType returns HookContentType by given name.
func (HookContentType) Name ¶
func (t HookContentType) Name() string
Name returns the name of a given web hook's content type
type HookEvent ¶
type HookEvent struct { PushOnly bool `json:"push_only"` SendEverything bool `json:"send_everything"` ChooseEvents bool `json:"choose_events"` BranchFilter string `json:"branch_filter"` HookEvents `json:"events"` }
HookEvent represents events that will delivery hook.
type HookEventType ¶
type HookEventType string
HookEventType is the type of an hook event
const ( HookEventCreate HookEventType = "create" HookEventDelete HookEventType = "delete" HookEventFork HookEventType = "fork" HookEventPush HookEventType = "push" HookEventIssues HookEventType = "issues" HookEventIssueAssign HookEventType = "issue_assign" HookEventIssueLabel HookEventType = "issue_label" HookEventIssueMilestone HookEventType = "issue_milestone" HookEventIssueComment HookEventType = "issue_comment" HookEventPullRequest HookEventType = "pull_request" HookEventPullRequestAssign HookEventType = "pull_request_assign" HookEventPullRequestLabel HookEventType = "pull_request_label" HookEventPullRequestMilestone HookEventType = "pull_request_milestone" HookEventPullRequestComment HookEventType = "pull_request_comment" HookEventPullRequestReviewApproved HookEventType = "pull_request_review_approved" HookEventPullRequestReviewRejected HookEventType = "pull_request_review_rejected" HookEventPullRequestReviewComment HookEventType = "pull_request_review_comment" HookEventPullRequestSync HookEventType = "pull_request_sync" HookEventRepository HookEventType = "repository" HookEventRelease HookEventType = "release" )
Types of hook events
func (HookEventType) Event ¶
func (h HookEventType) Event() string
Event returns the HookEventType as an event string
type HookEvents ¶
type HookEvents struct { Create bool `json:"create"` Delete bool `json:"delete"` Fork bool `json:"fork"` Issues bool `json:"issues"` IssueAssign bool `json:"issue_assign"` IssueLabel bool `json:"issue_label"` IssueMilestone bool `json:"issue_milestone"` IssueComment bool `json:"issue_comment"` Push bool `json:"push"` PullRequest bool `json:"pull_request"` PullRequestAssign bool `json:"pull_request_assign"` PullRequestLabel bool `json:"pull_request_label"` PullRequestMilestone bool `json:"pull_request_milestone"` PullRequestComment bool `json:"pull_request_comment"` PullRequestReview bool `json:"pull_request_review"` PullRequestSync bool `json:"pull_request_sync"` Repository bool `json:"repository"` Release bool `json:"release"` }
HookEvents is a set of web hook events
type HookRequest ¶
type HookRequest struct { URL string `json:"url"` HTTPMethod string `json:"http_method"` Headers map[string]string `json:"headers"` }
HookRequest represents hook task request information.
type HookResponse ¶
type HookResponse struct { Status int `json:"status"` Headers map[string]string `json:"headers"` Body string `json:"body"` }
HookResponse represents hook task response information.
type HookTask ¶
type HookTask struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX"` HookID int64 UUID string api.Payloader `xorm:"-"` PayloadContent string `xorm:"TEXT"` EventType HookEventType IsDelivered bool Delivered int64 DeliveredString string `xorm:"-"` // History info. IsSucceed bool RequestContent string `xorm:"TEXT"` RequestInfo *HookRequest `xorm:"-"` ResponseContent string `xorm:"TEXT"` ResponseInfo *HookResponse `xorm:"-"` }
HookTask represents a hook task.
func FindRepoUndeliveredHookTasks ¶
FindRepoUndeliveredHookTasks represents find the undelivered hook tasks of one repository
func FindUndeliveredHookTasks ¶
FindUndeliveredHookTasks represents find the undelivered hook tasks
func ReplayHookTask ¶
ReplayHookTask copies a hook task to get re-delivered
func (*HookTask) AfterLoad ¶
func (t *HookTask) AfterLoad()
AfterLoad updates the webhook object upon setting a column
func (*HookTask) BeforeUpdate ¶
func (t *HookTask) BeforeUpdate()
BeforeUpdate will be invoked by XORM before updating a record representing this object
type HookTaskCleanupType ¶
type HookTaskCleanupType int
HookTaskCleanupType is the type of cleanup to perform on hook_task
const ( // OlderThan hook_task rows will be cleaned up by the age of the row OlderThan HookTaskCleanupType = iota // PerWebhook hook_task rows will be cleaned up by leaving the most recent deliveries for each webhook PerWebhook )
func ToHookTaskCleanupType ¶
func ToHookTaskCleanupType(name string) HookTaskCleanupType
ToHookTaskCleanupType returns HookTaskCleanupType by given name.
type HookType ¶
type HookType = string
HookType is the type of a webhook
const ( GITEA HookType = "gitea" GOGS HookType = "gogs" SLACK HookType = "slack" DISCORD HookType = "discord" DINGTALK HookType = "dingtalk" TELEGRAM HookType = "telegram" MSTEAMS HookType = "msteams" FEISHU HookType = "feishu" MATRIX HookType = "matrix" WECHATWORK HookType = "wechatwork" )
Types of webhooks
type ListWebhookOptions ¶
type ListWebhookOptions struct { db.ListOptions RepoID int64 OrgID int64 IsActive util.OptionalBool }
ListWebhookOptions are options to filter webhooks on ListWebhooksByOpts
type Webhook ¶
type Webhook struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX"` // An ID of 0 indicates either a default or system webhook OrgID int64 `xorm:"INDEX"` IsSystemWebhook bool URL string `xorm:"url TEXT"` HTTPMethod string `xorm:"http_method"` ContentType HookContentType Secret string `xorm:"TEXT"` Events string `xorm:"TEXT"` *HookEvent `xorm:"-"` IsActive bool `xorm:"INDEX"` Type HookType `xorm:"VARCHAR(16) 'type'"` Meta string `xorm:"TEXT"` // store hook-specific attributes LastStatus HookStatus // Last delivery status CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` }
Webhook represents a web hook object.
func GetDefaultWebhooks ¶
GetDefaultWebhooks returns all admin-default webhooks.
func GetSystemOrDefaultWebhook ¶
GetSystemOrDefaultWebhook returns admin system or default webhook by given ID.
func GetSystemWebhooks ¶
func GetSystemWebhooks(isActive util.OptionalBool) ([]*Webhook, error)
GetSystemWebhooks returns all admin system webhooks.
func GetWebhookByID ¶
GetWebhookByID returns webhook of repository by given ID.
func GetWebhookByOrgID ¶
GetWebhookByOrgID returns webhook of organization by given ID.
func GetWebhookByRepoID ¶
GetWebhookByRepoID returns webhook of repository by given ID.
func ListWebhooksByOpts ¶
func ListWebhooksByOpts(opts *ListWebhookOptions) ([]*Webhook, error)
ListWebhooksByOpts return webhooks based on options
func (*Webhook) AfterLoad ¶
func (w *Webhook) AfterLoad()
AfterLoad updates the webhook object upon setting a column
func (*Webhook) EventCheckers ¶
func (w *Webhook) EventCheckers() []struct { Has func() bool Type HookEventType }
EventCheckers returns event checkers
func (*Webhook) EventsArray ¶
EventsArray returns an array of hook events
func (*Webhook) HasCreateEvent ¶
HasCreateEvent returns true if hook enabled create event.
func (*Webhook) HasDeleteEvent ¶
HasDeleteEvent returns true if hook enabled delete event.
func (*Webhook) HasForkEvent ¶
HasForkEvent returns true if hook enabled fork event.
func (*Webhook) HasIssueCommentEvent ¶
HasIssueCommentEvent returns true if hook enabled issue_comment event.
func (*Webhook) HasIssuesAssignEvent ¶
HasIssuesAssignEvent returns true if hook enabled issues assign event.
func (*Webhook) HasIssuesEvent ¶
HasIssuesEvent returns true if hook enabled issues event.
func (*Webhook) HasIssuesLabelEvent ¶
HasIssuesLabelEvent returns true if hook enabled issues label event.
func (*Webhook) HasIssuesMilestoneEvent ¶
HasIssuesMilestoneEvent returns true if hook enabled issues milestone event.
func (*Webhook) HasPullRequestApprovedEvent ¶
HasPullRequestApprovedEvent returns true if hook enabled pull request review event.
func (*Webhook) HasPullRequestAssignEvent ¶
HasPullRequestAssignEvent returns true if hook enabled pull request assign event.
func (*Webhook) HasPullRequestCommentEvent ¶
HasPullRequestCommentEvent returns true if hook enabled pull_request_comment event.
func (*Webhook) HasPullRequestEvent ¶
HasPullRequestEvent returns true if hook enabled pull request event.
func (*Webhook) HasPullRequestLabelEvent ¶
HasPullRequestLabelEvent returns true if hook enabled pull request label event.
func (*Webhook) HasPullRequestMilestoneEvent ¶
HasPullRequestMilestoneEvent returns true if hook enabled pull request milestone event.
func (*Webhook) HasPullRequestRejectedEvent ¶
HasPullRequestRejectedEvent returns true if hook enabled pull request review event.
func (*Webhook) HasPullRequestReviewCommentEvent ¶
HasPullRequestReviewCommentEvent returns true if hook enabled pull request review event.
func (*Webhook) HasPullRequestSyncEvent ¶
HasPullRequestSyncEvent returns true if hook enabled pull request sync event.
func (*Webhook) HasPushEvent ¶
HasPushEvent returns true if hook enabled push event.
func (*Webhook) HasReleaseEvent ¶
HasReleaseEvent returns if hook enabled release event.
func (*Webhook) HasRepositoryEvent ¶
HasRepositoryEvent returns if hook enabled repository event.
func (*Webhook) UpdateEvent ¶
UpdateEvent handles conversion from HookEvent to Events.