MCPcopy Create free account
hub / github.com/gogs/gogs / getDingtalkReleasePayload

Function getDingtalkReleasePayload

internal/database/webhook_dingtalk.go:244–269  ·  view source on GitHub ↗
(p *api.ReleasePayload)

Source from the content-addressed store, hash-verified

242}
243
244func getDingtalkReleasePayload(p *api.ReleasePayload) *DingtalkPayload {
245 releaseURL := p.Repository.HTMLURL + "/src/" + p.Release.TagName
246
247 author := p.Release.Author.FullName
248 if author == "" {
249 author = p.Release.Author.UserName
250 }
251
252 actionCard := NewDingtalkActionCard("View Release", releaseURL)
253 actionCard.Text += "# New Release Published"
254 actionCard.Text += "\n- Repo: " + MarkdownLinkFormatter(p.Repository.HTMLURL, p.Repository.Name)
255 actionCard.Text += "\n- Tag: " + MarkdownLinkFormatter(releaseURL, p.Release.TagName)
256 actionCard.Text += "\n- Author: " + author
257 actionCard.Text += fmt.Sprintf("\n- Draft?: %t", p.Release.Draft)
258 actionCard.Text += fmt.Sprintf("\n- Pre Release?: %t", p.Release.Prerelease)
259 actionCard.Text += "\n- Title: " + p.Release.Name
260
261 if p.Release.Body != "" {
262 actionCard.Text += "\n- Note: " + p.Release.Body
263 }
264
265 return &DingtalkPayload{
266 MsgType: "actionCard",
267 ActionCard: actionCard,
268 }
269}
270
271// MarkdownLinkFormatter formats link address and title into Markdown style.
272func MarkdownLinkFormatter(link, text string) string {

Callers 1

GetDingtalkPayloadFunction · 0.85

Calls 2

NewDingtalkActionCardFunction · 0.85
MarkdownLinkFormatterFunction · 0.85

Tested by

no test coverage detected