(p *api.PullRequestPayload, slack *SlackMeta)
| 224 | } |
| 225 | |
| 226 | func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) *SlackPayload { |
| 227 | senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName) |
| 228 | titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index), |
| 229 | fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title)) |
| 230 | var text, title, attachmentText string |
| 231 | switch p.Action { |
| 232 | case api.HOOK_ISSUE_OPENED: |
| 233 | text = fmt.Sprintf("[%s] Pull request submitted by %s", p.Repository.FullName, senderLink) |
| 234 | title = titleLink |
| 235 | attachmentText = SlackTextFormatter(p.PullRequest.Body) |
| 236 | case api.HOOK_ISSUE_CLOSED: |
| 237 | if p.PullRequest.HasMerged { |
| 238 | text = fmt.Sprintf("[%s] Pull request merged: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 239 | } else { |
| 240 | text = fmt.Sprintf("[%s] Pull request closed: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 241 | } |
| 242 | case api.HOOK_ISSUE_REOPENED: |
| 243 | text = fmt.Sprintf("[%s] Pull request re-opened: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 244 | case api.HOOK_ISSUE_EDITED: |
| 245 | text = fmt.Sprintf("[%s] Pull request edited: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 246 | attachmentText = SlackTextFormatter(p.PullRequest.Body) |
| 247 | case api.HOOK_ISSUE_ASSIGNED: |
| 248 | text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName, |
| 249 | SlackLinkFormatter(conf.Server.ExternalURL+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName), |
| 250 | titleLink, senderLink) |
| 251 | case api.HOOK_ISSUE_UNASSIGNED: |
| 252 | text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 253 | case api.HOOK_ISSUE_LABEL_UPDATED: |
| 254 | text = fmt.Sprintf("[%s] Pull request labels updated: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 255 | case api.HOOK_ISSUE_LABEL_CLEARED: |
| 256 | text = fmt.Sprintf("[%s] Pull request labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 257 | case api.HOOK_ISSUE_SYNCHRONIZED: |
| 258 | text = fmt.Sprintf("[%s] Pull request synchronized: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 259 | case api.HOOK_ISSUE_MILESTONED: |
| 260 | text = fmt.Sprintf("[%s] Pull request milestoned: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 261 | case api.HOOK_ISSUE_DEMILESTONED: |
| 262 | text = fmt.Sprintf("[%s] Pull request demilestoned: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 263 | } |
| 264 | |
| 265 | return &SlackPayload{ |
| 266 | Channel: slack.Channel, |
| 267 | Text: text, |
| 268 | Username: slack.Username, |
| 269 | IconURL: slack.IconURL, |
| 270 | Attachments: []*SlackAttachment{{ |
| 271 | Color: slack.Color, |
| 272 | Title: title, |
| 273 | Text: attachmentText, |
| 274 | }}, |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | func getSlackReleasePayload(p *api.ReleasePayload) *SlackPayload { |
| 279 | repoLink := SlackLinkFormatter(p.Repository.HTMLURL, p.Repository.Name) |
no test coverage detected