Documentation ¶
Index ¶
- 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 CreateWebhook(ctx context.Context, w *Webhook) error
- func CreateWebhooks(ctx context.Context, ws []*Webhook) error
- func DeleteDefaultSystemWebhook(ctx context.Context, id int64) error
- func DeleteWebhookByID(ctx context.Context, id int64) (err error)
- func DeleteWebhookByOwnerID(ctx context.Context, ownerID, id int64) error
- func DeleteWebhookByRepoID(ctx context.Context, repoID, id int64) error
- func FindUndeliveredHookTaskIDs(ctx context.Context, lowerID int64) ([]int64, error)
- func IsErrHookTaskNotExist(err error) bool
- func IsErrWebhookNotExist(err error) bool
- func IsValidHookContentType(name string) bool
- func MarkTaskDelivered(ctx context.Context, task *HookTask) (bool, error)
- func UpdateHookTask(t *HookTask) error
- func UpdateWebhook(w *Webhook) error
- func UpdateWebhookLastStatus(w *Webhook) error
- type ErrHookTaskNotExist
- type ErrWebhookNotExist
- type HookContentType
- type HookRequest
- type HookResponse
- type HookTask
- type HookTaskCleanupType
- type ListWebhookOptions
- type Webhook
- func GetDefaultWebhooks(ctx context.Context) ([]*Webhook, error)
- func GetSystemOrDefaultWebhook(ctx context.Context, id int64) (*Webhook, error)
- func GetSystemWebhooks(ctx context.Context, isActive util.OptionalBool) ([]*Webhook, error)
- func GetWebhookByID(ctx context.Context, id int64) (*Webhook, error)
- func GetWebhookByOwnerID(ctx context.Context, ownerID, id int64) (*Webhook, error)
- func GetWebhookByRepoID(ctx context.Context, repoID, id int64) (*Webhook, error)
- func ListWebhooksByOpts(ctx context.Context, 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) HasPackageEvent() 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) HasPullRequestReviewRequestEvent() bool
- func (w *Webhook) HasPullRequestSyncEvent() bool
- func (w *Webhook) HasPushEvent() bool
- func (w *Webhook) HasReleaseEvent() bool
- func (w *Webhook) HasRepositoryEvent() bool
- func (w *Webhook) HasWikiEvent() bool
- func (w Webhook) HeaderAuthorization() (string, error)
- func (w *Webhook) History(page int) ([]*HookTask, error)
- func (w *Webhook) SetHeaderAuthorization(cleartext string) error
- func (w *Webhook) UpdateEvent() error
Constants ¶
This section is empty.
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 CreateWebhook ¶
CreateWebhook creates a new web hook.
func CreateWebhooks ¶ added in v1.17.0
CreateWebhooks creates multiple web hooks
func DeleteDefaultSystemWebhook ¶
DeleteDefaultSystemWebhook deletes an admin-configured default or system webhook (where Org and Repo ID both 0)
func DeleteWebhookByID ¶ added in v1.20.6
DeleteWebhookByID uses argument bean as query condition, ID must be specified and do not assign unnecessary fields.
func DeleteWebhookByOwnerID ¶ added in v1.20.0
DeleteWebhookByOwnerID deletes webhook of a user or organization by given ID.
func DeleteWebhookByRepoID ¶
DeleteWebhookByRepoID deletes webhook of repository by given ID.
func FindUndeliveredHookTaskIDs ¶ added in v1.17.4
FindUndeliveredHookTaskIDs will find the next 100 undelivered hook tasks with ID greater than the provided lowerID
func IsErrHookTaskNotExist ¶
IsErrHookTaskNotExist checks if an error is a ErrHookTaskNotExist.
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 MarkTaskDelivered ¶ added in v1.17.4
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
func (ErrHookTaskNotExist) Unwrap ¶ added in v1.17.4
func (err ErrHookTaskNotExist) Unwrap() error
type ErrWebhookNotExist ¶
type ErrWebhookNotExist struct {
ID int64
}
ErrWebhookNotExist represents a "WebhookNotExist" kind of error.
func (ErrWebhookNotExist) Error ¶
func (err ErrWebhookNotExist) Error() string
func (ErrWebhookNotExist) Unwrap ¶ added in v1.17.4
func (err ErrWebhookNotExist) Unwrap() error
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 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"` HookID int64 `xorm:"index"` UUID string `xorm:"unique"` api.Payloader `xorm:"-"` PayloadContent string `xorm:"LONGTEXT"` EventType webhook_module.HookEventType IsDelivered bool Delivered timeutil.TimeStampNano // History info. IsSucceed bool RequestContent string `xorm:"LONGTEXT"` RequestInfo *HookRequest `xorm:"-"` ResponseContent string `xorm:"LONGTEXT"` ResponseInfo *HookResponse `xorm:"-"` }
HookTask represents a hook task.
func CreateHookTask ¶
CreateHookTask creates a new hook task, it handles conversion from Payload to PayloadContent.
func GetHookTaskByID ¶ added in v1.17.4
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 ListWebhookOptions ¶
type ListWebhookOptions struct { db.ListOptions RepoID int64 OwnerID 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 OwnerID 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"` *webhook_module.HookEvent `xorm:"-"` IsActive bool `xorm:"INDEX"` Type webhook_module.HookType `xorm:"VARCHAR(16) 'type'"` Meta string `xorm:"TEXT"` // store hook-specific attributes LastStatus webhook_module.HookStatus // Last delivery status // HeaderAuthorizationEncrypted should be accessed using HeaderAuthorization() and SetHeaderAuthorization() HeaderAuthorizationEncrypted string `xorm:"TEXT"` 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 ¶
GetSystemWebhooks returns all admin system webhooks.
func GetWebhookByID ¶
GetWebhookByID returns webhook of repository by given ID.
func GetWebhookByOwnerID ¶ added in v1.20.0
GetWebhookByOwnerID returns webhook of a user or organization by given ID.
func GetWebhookByRepoID ¶
GetWebhookByRepoID returns webhook of repository by given ID.
func ListWebhooksByOpts ¶
func ListWebhooksByOpts(ctx context.Context, 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 webhook_module.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) HasPackageEvent ¶ added in v1.17.0
HasPackageEvent returns if hook enabled package 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) HasPullRequestReviewRequestEvent ¶ added in v1.20.0
HasPullRequestReviewRequestEvent returns true if hook enabled pull request review request 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) HasWikiEvent ¶ added in v1.17.4
HasWikiEvent returns true if hook enabled wiki event.
func (Webhook) HeaderAuthorization ¶ added in v1.17.4
HeaderAuthorization returns the decrypted Authorization header. Not on the reference (*w), to be accessible on WebhooksNew.
func (*Webhook) SetHeaderAuthorization ¶ added in v1.17.4
SetHeaderAuthorization encrypts and sets the Authorization header.
func (*Webhook) UpdateEvent ¶
UpdateEvent handles conversion from HookEvent to Events.