code.gitea.io/gitea@v1.19.3/modules/webhook/type.go (about)

     1  // Copyright 2022 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package webhook
     5  
     6  // HookEventType is the type of a hook event
     7  type HookEventType string
     8  
     9  // Types of hook events
    10  const (
    11  	HookEventCreate                    HookEventType = "create"
    12  	HookEventDelete                    HookEventType = "delete"
    13  	HookEventFork                      HookEventType = "fork"
    14  	HookEventPush                      HookEventType = "push"
    15  	HookEventIssues                    HookEventType = "issues"
    16  	HookEventIssueAssign               HookEventType = "issue_assign"
    17  	HookEventIssueLabel                HookEventType = "issue_label"
    18  	HookEventIssueMilestone            HookEventType = "issue_milestone"
    19  	HookEventIssueComment              HookEventType = "issue_comment"
    20  	HookEventPullRequest               HookEventType = "pull_request"
    21  	HookEventPullRequestAssign         HookEventType = "pull_request_assign"
    22  	HookEventPullRequestLabel          HookEventType = "pull_request_label"
    23  	HookEventPullRequestMilestone      HookEventType = "pull_request_milestone"
    24  	HookEventPullRequestComment        HookEventType = "pull_request_comment"
    25  	HookEventPullRequestReviewApproved HookEventType = "pull_request_review_approved"
    26  	HookEventPullRequestReviewRejected HookEventType = "pull_request_review_rejected"
    27  	HookEventPullRequestReviewComment  HookEventType = "pull_request_review_comment"
    28  	HookEventPullRequestSync           HookEventType = "pull_request_sync"
    29  	HookEventWiki                      HookEventType = "wiki"
    30  	HookEventRepository                HookEventType = "repository"
    31  	HookEventRelease                   HookEventType = "release"
    32  	HookEventPackage                   HookEventType = "package"
    33  )
    34  
    35  // Event returns the HookEventType as an event string
    36  func (h HookEventType) Event() string {
    37  	switch h {
    38  	case HookEventCreate:
    39  		return "create"
    40  	case HookEventDelete:
    41  		return "delete"
    42  	case HookEventFork:
    43  		return "fork"
    44  	case HookEventPush:
    45  		return "push"
    46  	case HookEventIssues, HookEventIssueAssign, HookEventIssueLabel, HookEventIssueMilestone:
    47  		return "issues"
    48  	case HookEventPullRequest, HookEventPullRequestAssign, HookEventPullRequestLabel, HookEventPullRequestMilestone,
    49  		HookEventPullRequestSync:
    50  		return "pull_request"
    51  	case HookEventIssueComment, HookEventPullRequestComment:
    52  		return "issue_comment"
    53  	case HookEventPullRequestReviewApproved:
    54  		return "pull_request_approved"
    55  	case HookEventPullRequestReviewRejected:
    56  		return "pull_request_rejected"
    57  	case HookEventPullRequestReviewComment:
    58  		return "pull_request_comment"
    59  	case HookEventWiki:
    60  		return "wiki"
    61  	case HookEventRepository:
    62  		return "repository"
    63  	case HookEventRelease:
    64  		return "release"
    65  	}
    66  	return ""
    67  }
    68  
    69  // HookType is the type of a webhook
    70  type HookType = string
    71  
    72  // Types of webhooks
    73  const (
    74  	GITEA      HookType = "gitea"
    75  	GOGS       HookType = "gogs"
    76  	SLACK      HookType = "slack"
    77  	DISCORD    HookType = "discord"
    78  	DINGTALK   HookType = "dingtalk"
    79  	TELEGRAM   HookType = "telegram"
    80  	MSTEAMS    HookType = "msteams"
    81  	FEISHU     HookType = "feishu"
    82  	MATRIX     HookType = "matrix"
    83  	WECHATWORK HookType = "wechatwork"
    84  	PACKAGIST  HookType = "packagist"
    85  )
    86  
    87  // HookStatus is the status of a web hook
    88  type HookStatus int
    89  
    90  // Possible statuses of a web hook
    91  const (
    92  	HookStatusNone HookStatus = iota
    93  	HookStatusSucceed
    94  	HookStatusFail
    95  )