Open the DingTalk link in browser (#17084)

https://developers.dingtalk.com/document/app/message-link-description

To open the link in browser, we should use this URL: `"dingtalk://dingtalkclient/page/link?pc_slide=false&url=" + url.QueryEscape(singleURL)`

Otherwise the page is displayed inside DingTalk client, it makes users very difficult to visit non-public URLs in DingTalk webhook messages.
This commit is contained in:
wxiaoguang 2021-09-19 03:35:23 +08:00 committed by GitHub
parent ea207f694d
commit 6532aa2ed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 13 deletions

View file

@ -6,6 +6,7 @@ package webhook
import (
"fmt"
"net/url"
"strings"
"code.gitea.io/gitea/models"
@ -175,7 +176,10 @@ func createDingtalkPayload(title, text, singleTitle, singleURL string) *Dingtalk
Title: strings.TrimSpace(title),
HideAvatar: "0",
SingleTitle: singleTitle,
SingleURL: singleURL,
// https://developers.dingtalk.com/document/app/message-link-description
// to open the link in browser, we should use this URL, otherwise the page is displayed inside DingTalk client, very difficult to visit non-public URLs.
SingleURL: "dingtalk://dingtalkclient/page/link?pc_slide=false&url=" + url.QueryEscape(singleURL),
},
}
}