(p *api.IssueCommentPayload, slack *SlackMeta)
| 190 | } |
| 191 | |
| 192 | func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) *SlackPayload { |
| 193 | senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName) |
| 194 | titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d#%s", p.Repository.HTMLURL, p.Issue.Index, CommentHashTag(p.Comment.ID)), |
| 195 | fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title)) |
| 196 | var text, title, attachmentText string |
| 197 | switch p.Action { |
| 198 | case api.HOOK_ISSUE_COMMENT_CREATED: |
| 199 | text = fmt.Sprintf("[%s] New comment created by %s", p.Repository.FullName, senderLink) |
| 200 | title = titleLink |
| 201 | attachmentText = SlackTextFormatter(p.Comment.Body) |
| 202 | case api.HOOK_ISSUE_COMMENT_EDITED: |
| 203 | text = fmt.Sprintf("[%s] Comment edited by %s", p.Repository.FullName, senderLink) |
| 204 | title = titleLink |
| 205 | attachmentText = SlackTextFormatter(p.Comment.Body) |
| 206 | case api.HOOK_ISSUE_COMMENT_DELETED: |
| 207 | text = fmt.Sprintf("[%s] Comment deleted by %s", p.Repository.FullName, senderLink) |
| 208 | title = SlackLinkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Issue.Index), |
| 209 | fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title)) |
| 210 | attachmentText = SlackTextFormatter(p.Comment.Body) |
| 211 | } |
| 212 | |
| 213 | return &SlackPayload{ |
| 214 | Channel: slack.Channel, |
| 215 | Text: text, |
| 216 | Username: slack.Username, |
| 217 | IconURL: slack.IconURL, |
| 218 | Attachments: []*SlackAttachment{{ |
| 219 | Color: slack.Color, |
| 220 | Title: title, |
| 221 | Text: attachmentText, |
| 222 | }}, |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) *SlackPayload { |
| 227 | senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName) |
no test coverage detected