You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

type.go 3.4KB

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