(p *api.IssuesPayload, slack *SlackMeta)
| 144 | } |
| 145 | |
| 146 | func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) *SlackPayload { |
| 147 | senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName) |
| 148 | titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index), |
| 149 | fmt.Sprintf("#%d %s", p.Index, p.Issue.Title)) |
| 150 | var text, title, attachmentText string |
| 151 | switch p.Action { |
| 152 | case api.HOOK_ISSUE_OPENED: |
| 153 | text = fmt.Sprintf("[%s] New issue created by %s", p.Repository.FullName, senderLink) |
| 154 | title = titleLink |
| 155 | attachmentText = SlackTextFormatter(p.Issue.Body) |
| 156 | case api.HOOK_ISSUE_CLOSED: |
| 157 | text = fmt.Sprintf("[%s] Issue closed: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 158 | case api.HOOK_ISSUE_REOPENED: |
| 159 | text = fmt.Sprintf("[%s] Issue re-opened: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 160 | case api.HOOK_ISSUE_EDITED: |
| 161 | text = fmt.Sprintf("[%s] Issue edited: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 162 | attachmentText = SlackTextFormatter(p.Issue.Body) |
| 163 | case api.HOOK_ISSUE_ASSIGNED: |
| 164 | text = fmt.Sprintf("[%s] Issue assigned to %s: %s by %s", p.Repository.FullName, |
| 165 | SlackLinkFormatter(conf.Server.ExternalURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName), |
| 166 | titleLink, senderLink) |
| 167 | case api.HOOK_ISSUE_UNASSIGNED: |
| 168 | text = fmt.Sprintf("[%s] Issue unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 169 | case api.HOOK_ISSUE_LABEL_UPDATED: |
| 170 | text = fmt.Sprintf("[%s] Issue labels updated: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 171 | case api.HOOK_ISSUE_LABEL_CLEARED: |
| 172 | text = fmt.Sprintf("[%s] Issue labels cleared: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 173 | case api.HOOK_ISSUE_MILESTONED: |
| 174 | text = fmt.Sprintf("[%s] Issue milestoned: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 175 | case api.HOOK_ISSUE_DEMILESTONED: |
| 176 | text = fmt.Sprintf("[%s] Issue demilestoned: %s by %s", p.Repository.FullName, titleLink, senderLink) |
| 177 | } |
| 178 | |
| 179 | return &SlackPayload{ |
| 180 | Channel: slack.Channel, |
| 181 | Text: text, |
| 182 | Username: slack.Username, |
| 183 | IconURL: slack.IconURL, |
| 184 | Attachments: []*SlackAttachment{{ |
| 185 | Color: slack.Color, |
| 186 | Title: title, |
| 187 | Text: attachmentText, |
| 188 | }}, |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) *SlackPayload { |
| 193 | senderLink := SlackLinkFormatter(conf.Server.ExternalURL+p.Sender.UserName, p.Sender.UserName) |
no test coverage detected