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

Function getDiscordIssueCommentPayload

internal/database/webhook_discord.go:242–279  ·  view source on GitHub ↗
(p *api.IssueCommentPayload, slack *SlackMeta)

Source from the content-addressed store, hash-verified

240}
241
242func getDiscordIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) *DiscordPayload {
243 title := fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title)
244 url := fmt.Sprintf("%s/issues/%d#%s", p.Repository.HTMLURL, p.Issue.Index, CommentHashTag(p.Comment.ID))
245 content := ""
246 fields := make([]*DiscordEmbedFieldObject, 0, 1)
247 switch p.Action {
248 case api.HOOK_ISSUE_COMMENT_CREATED:
249 title = "New comment: " + title
250 content = p.Comment.Body
251 case api.HOOK_ISSUE_COMMENT_EDITED:
252 title = "Comment edited: " + title
253 content = p.Comment.Body
254 case api.HOOK_ISSUE_COMMENT_DELETED:
255 title = "Comment deleted: " + title
256 url = fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Issue.Index)
257 content = p.Comment.Body
258 }
259
260 color, _ := strconv.ParseInt(strings.TrimLeft(slack.Color, "#"), 16, 32)
261 return &DiscordPayload{
262 Username: slack.Username,
263 AvatarURL: slack.IconURL,
264 Embeds: []*DiscordEmbedObject{{
265 Title: title,
266 Description: content,
267 URL: url,
268 Color: int(color),
269 Footer: &DiscordEmbedFooterObject{
270 Text: p.Repository.FullName,
271 },
272 Author: &DiscordEmbedAuthorObject{
273 Name: p.Sender.UserName,
274 IconURL: p.Sender.AvatarUrl,
275 },
276 Fields: fields,
277 }},
278 }
279}
280
281func getDiscordPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) *DiscordPayload {
282 title := fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title)

Callers 1

GetDiscordPayloadFunction · 0.85

Calls 1

CommentHashTagFunction · 0.85

Tested by

no test coverage detected