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

Function getDingtalkPullRequestPayload

internal/database/webhook_dingtalk.go:209–242  ·  view source on GitHub ↗
(p *api.PullRequestPayload)

Source from the content-addressed store, hash-verified

207}
208
209func getDingtalkPullRequestPayload(p *api.PullRequestPayload) *DingtalkPayload {
210 title := "# Pull Request " + strings.Title(string(p.Action))
211 if p.Action == api.HOOK_ISSUE_CLOSED && p.PullRequest.HasMerged {
212 title = "# Pull Request Merged"
213 }
214
215 pullRequestURL := fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index)
216
217 content := "- PR: " + MarkdownLinkFormatter(pullRequestURL, fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
218 switch p.Action {
219 case api.HOOK_ISSUE_ASSIGNED:
220 content += "\n- New Assignee: **" + p.PullRequest.Assignee.UserName + "**"
221 case api.HOOK_ISSUE_MILESTONED:
222 content += "\n- New Milestone: *" + p.PullRequest.Milestone.Title + "*"
223 case api.HOOK_ISSUE_LABEL_UPDATED:
224 labels := make([]string, len(p.PullRequest.Labels))
225 for i, label := range p.PullRequest.Labels {
226 labels[i] = "**" + label.Name + "**"
227 }
228 content += "\n- New Labels: " + strings.Join(labels, ",")
229 }
230
231 actionCard := NewDingtalkActionCard("View Pull Request", pullRequestURL)
232 actionCard.Text += title + "\n" + content
233
234 if p.Action == api.HOOK_ISSUE_OPENED || p.Action == api.HOOK_ISSUE_EDITED {
235 actionCard.Text += "\n> " + p.PullRequest.Body
236 }
237
238 return &DingtalkPayload{
239 MsgType: "actionCard",
240 ActionCard: actionCard,
241 }
242}
243
244func getDingtalkReleasePayload(p *api.ReleasePayload) *DingtalkPayload {
245 releaseURL := p.Repository.HTMLURL + "/src/" + p.Release.TagName

Callers 1

GetDingtalkPayloadFunction · 0.85

Calls 4

stringFunction · 0.85
MarkdownLinkFormatterFunction · 0.85
NewDingtalkActionCardFunction · 0.85
TitleMethod · 0.80

Tested by

no test coverage detected