summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2020-01-08 11:45:24 -0600
committerAntoine GIRARD <sapk@users.noreply.github.com>2020-01-08 18:45:24 +0100
commitf8dcc5f9f8e389218f1908ad9d5fe2044102abf1 (patch)
tree0710644a8e9597195372bc285f5113d59410d00b /modules
parentb822518e396a569b89aab6d621b01eefe723caa7 (diff)
downloadgitea-f8dcc5f9f8e389218f1908ad9d5fe2044102abf1.tar.gz
gitea-f8dcc5f9f8e389218f1908ad9d5fe2044102abf1.zip
Add PR review webhook to Telegram (#9653)
Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/webhook/telegram.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/webhook/telegram.go b/modules/webhook/telegram.go
index 42adb40be2..47d54f7cb9 100644
--- a/modules/webhook/telegram.go
+++ b/modules/webhook/telegram.go
@@ -148,6 +148,25 @@ func getTelegramPullRequestPayload(p *api.PullRequestPayload) (*TelegramPayload,
}, nil
}
+func getTelegramPullRequestApprovalPayload(p *api.PullRequestPayload, event models.HookEventType) (*TelegramPayload, error) {
+ var text, attachmentText string
+ switch p.Action {
+ case api.HookIssueSynchronized:
+ action, err := parseHookPullRequestEventType(event)
+ if err != nil {
+ return nil, err
+ }
+
+ text = fmt.Sprintf("[%s] Pull request review %s: #%d %s", p.Repository.FullName, action, p.Index, p.PullRequest.Title)
+ attachmentText = p.Review.Content
+
+ }
+
+ return &TelegramPayload{
+ Message: text + "\n" + attachmentText,
+ }, nil
+}
+
func getTelegramRepositoryPayload(p *api.RepositoryPayload) (*TelegramPayload, error) {
var title string
switch p.Action {
@@ -192,6 +211,8 @@ func GetTelegramPayload(p api.Payloader, event models.HookEventType, meta string
return getTelegramPushPayload(p.(*api.PushPayload))
case models.HookEventPullRequest:
return getTelegramPullRequestPayload(p.(*api.PullRequestPayload))
+ case models.HookEventPullRequestRejected, models.HookEventPullRequestApproved, models.HookEventPullRequestComment:
+ return getTelegramPullRequestApprovalPayload(p.(*api.PullRequestPayload), event)
case models.HookEventRepository:
return getTelegramRepositoryPayload(p.(*api.RepositoryPayload))
case models.HookEventRelease: