Documentation ¶
Index ¶
- func FormatCreateMsg(ref string, refType string, repo string) string
- func FormatDeleteMsg(ref string, refType string, repo string) string
- func FormatForkMsg(original string, newFork string) string
- func FormatIssueCommentMsg(action gitea.HookIssueCommentAction, username string, issueNum int64, ...) (message string)
- func FormatIssueMsg(action gitea.HookIssueAction, username string, issueNum int64, repo string, ...) (message string)
- func FormatPullRequestMsg(action gitea.HookIssueAction, username string, repo string, prNum int64, ...) (message string)
- func FormatPushMsg(username string, repo string, branch string, numCommits int, messages []string, ...) (res string)
- func FormatReleaseMsg(action gitea.HookReleaseAction, username string, repo string, release string, ...) (message string)
- func FormatRepositoryMsg(action gitea.HookRepoAction, username string, repo string) (message string)
- func ParseWebhook(eventType EventType, payload []byte) (event interface{}, err error)
- type DB
- func (d *DB) CreateSubscription(convID chat1.ConvIDStr, repo string, oauthIdentifier string) error
- func (d *DB) DeleteSubscription(convID chat1.ConvIDStr, repo string) error
- func (d *DB) DeleteSubscriptionsForRepo(convID chat1.ConvIDStr, repo string) error
- func (d *DB) GetAllSubscriptionsForConvID(convID chat1.ConvIDStr) (res []string, err error)
- func (d *DB) GetSubscribedConvs(repo string) (res []chat1.ConvIDStr, err error)
- func (d *DB) GetSubscriptionExists(convID chat1.ConvIDStr, repo string) (exists bool, err error)
- func (d *DB) GetSubscriptionForRepoExists(convID chat1.ConvIDStr, repo string) (exists bool, err error)
- type EventType
- type HTTPSrv
- type Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatForkMsg ¶
func FormatIssueCommentMsg ¶
func FormatIssueMsg ¶
func FormatPullRequestMsg ¶
func FormatPushMsg ¶
func FormatPushMsg(username string, repo string, branch string, numCommits int, messages []string, commitURL string) (res string)
Borrowed from https://github.com/keybase/managed-bots/blob/master/base/git/git.go (3dbf0f6)
func FormatReleaseMsg ¶
func FormatRepositoryMsg ¶
func FormatRepositoryMsg(action gitea.HookRepoAction, username string, repo string) (message string)
func ParseWebhook ¶
ParseWebhook parses the event payload. For recognized event types, a value of the corresponding struct type will be returned. An error will be returned for unrecognized event types.
The payloads are defined in Gitea's source at modules/structs/hook.go
https://github.com/go-gitea/gitea/blob/master/modules/structs/hook.go
Example usage:
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { payload, err := ioutil.ReadAll(r.Body) if err != nil { ... } event, err := ParseWebhook(EventType(r), payload) if err != nil { ... } switch event := event.(type) { case *gitea.PushPayload: processPushEvent(event) case *gitea.ForkPayload: processForkEvent(event) ... } }
Types ¶
type DB ¶
func (*DB) CreateSubscription ¶
func (*DB) DeleteSubscription ¶
func (*DB) DeleteSubscriptionsForRepo ¶
func (*DB) GetAllSubscriptionsForConvID ¶
func (*DB) GetSubscribedConvs ¶
func (*DB) GetSubscriptionExists ¶
type EventType ¶
type EventType string
EventType represents a Gitea webhook event
const ( EventTypeCreate EventType = "create" EventTypeDelete EventType = "delete" EventTypeFork EventType = "fork" EventTypePush EventType = "push" EventTypeIssues EventType = "issues" EventTypeIssueComment EventType = "issue_comment" EventTypeRepository EventType = "repository" EventTypeRelease EventType = "release" EventTypePullRequest EventType = "pull_request" EventTypePullRequestApproved EventType = "pull_request_approved" EventTypePullRequestRejected EventType = "pull_request_rejected" EventTypePullRequestComment EventType = "pull_request_comment" )
List of supported events
Find them in Gitea's source at /models/webhook.go as HookEventType. To correlate with when each of these trigger, see the Trigger On -> Custom Events options when editing a repo's webhook in a Gitea project. Those descriptions are helpful.
func WebhookEventType ¶
WebhookEventType returns the event type for the given request.
type HTTPSrv ¶
func NewHTTPSrv ¶
func NewHTTPSrv(stats *base.StatsRegistry, kbc *kbchat.API, debugConfig *base.ChatDebugOutputConfig, db *DB, handler *Handler, secret string) *HTTPSrv
type Handler ¶
type Handler struct { *base.DebugOutput // contains filtered or unexported fields }
func NewHandler ¶
func (*Handler) HandleCommand ¶
func (h *Handler) HandleCommand(msg chat1.MsgSummary) error
func (*Handler) HandleNewConv ¶
func (h *Handler) HandleNewConv(conv chat1.ConvSummary) error