summaryrefslogtreecommitdiffstats
path: root/models/webhook_dingtalk.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/webhook_dingtalk.go')
-rw-r--r--models/webhook_dingtalk.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/models/webhook_dingtalk.go b/models/webhook_dingtalk.go
index 06388a6ba2..dbbbebcd9a 100644
--- a/models/webhook_dingtalk.go
+++ b/models/webhook_dingtalk.go
@@ -11,7 +11,6 @@ import (
"code.gitea.io/git"
api "code.gitea.io/sdk/gitea"
-
dingtalk "github.com/lunny/dingtalk_webhook"
)
@@ -271,6 +270,32 @@ func getDingtalkPullRequestPayload(p *api.PullRequestPayload) (*DingtalkPayload,
}, nil
}
+func getDingtalkPullRequestApprovalPayload(p *api.PullRequestPayload, event HookEventType) (*DingtalkPayload, error) {
+ var text, title string
+ switch p.Action {
+ case api.HookIssueSynchronized:
+ action, err := parseHookPullRequestEventType(event)
+ if err != nil {
+ return nil, err
+ }
+
+ title = fmt.Sprintf("[%s] Pull request review %s : #%d %s", p.Repository.FullName, action, p.Index, p.PullRequest.Title)
+ text = p.PullRequest.Body
+
+ }
+
+ return &DingtalkPayload{
+ MsgType: "actionCard",
+ ActionCard: dingtalk.ActionCard{
+ Text: title + "\r\n\r\n" + text,
+ Title: title,
+ HideAvatar: "0",
+ SingleTitle: "view pull request",
+ SingleURL: p.PullRequest.HTMLURL,
+ },
+ }, nil
+}
+
func getDingtalkRepositoryPayload(p *api.RepositoryPayload) (*DingtalkPayload, error) {
var title, url string
switch p.Action {
@@ -369,6 +394,8 @@ func GetDingtalkPayload(p api.Payloader, event HookEventType, meta string) (*Din
return getDingtalkPushPayload(p.(*api.PushPayload))
case HookEventPullRequest:
return getDingtalkPullRequestPayload(p.(*api.PullRequestPayload))
+ case HookEventPullRequestApproved, HookEventPullRequestRejected, HookEventPullRequestComment:
+ return getDingtalkPullRequestApprovalPayload(p.(*api.PullRequestPayload), event)
case HookEventRepository:
return getDingtalkRepositoryPayload(p.(*api.RepositoryPayload))
case HookEventRelease: