aboutsummaryrefslogtreecommitdiffstats
path: root/services/webhook/slack.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/webhook/slack.go')
-rw-r--r--services/webhook/slack.go28
1 files changed, 25 insertions, 3 deletions
diff --git a/services/webhook/slack.go b/services/webhook/slack.go
index c905e7a89f..3d645a55d0 100644
--- a/services/webhook/slack.go
+++ b/services/webhook/slack.go
@@ -84,9 +84,9 @@ func SlackLinkFormatter(url, text string) string {
// SlackLinkToRef slack-formatter link to a repo ref
func SlackLinkToRef(repoURL, ref string) string {
// FIXME: SHA1 hardcoded here
- url := git.RefURL(repoURL, ref)
- refName := git.RefName(ref).ShortName()
- return SlackLinkFormatter(url, refName)
+ refName := git.RefName(ref)
+ url := repoURL + "/src/" + refName.RefWebLinkPath()
+ return SlackLinkFormatter(url, refName.ShortName())
}
// Create implements payloadConvertor Create method
@@ -167,6 +167,24 @@ func (s slackConvertor) Package(p *api.PackagePayload) (SlackPayload, error) {
return s.createPayload(text, nil), nil
}
+func (s slackConvertor) Status(p *api.CommitStatusPayload) (SlackPayload, error) {
+ text, _ := getStatusPayloadInfo(p, SlackLinkFormatter, true)
+
+ return s.createPayload(text, nil), nil
+}
+
+func (s slackConvertor) WorkflowRun(p *api.WorkflowRunPayload) (SlackPayload, error) {
+ text, _ := getWorkflowRunPayloadInfo(p, SlackLinkFormatter, true)
+
+ return s.createPayload(text, nil), nil
+}
+
+func (s slackConvertor) WorkflowJob(p *api.WorkflowJobPayload) (SlackPayload, error) {
+ text, _ := getWorkflowJobPayloadInfo(p, SlackLinkFormatter, true)
+
+ return s.createPayload(text, nil), nil
+}
+
// Push implements payloadConvertor Push method
func (s slackConvertor) Push(p *api.PushPayload) (SlackPayload, error) {
// n new commits
@@ -295,6 +313,10 @@ func newSlackRequest(_ context.Context, w *webhook_model.Webhook, t *webhook_mod
return newJSONRequest(pc, w, t, true)
}
+func init() {
+ RegisterWebhookRequester(webhook_module.SLACK, newSlackRequest)
+}
+
var slackChannel = regexp.MustCompile(`^#?[a-z0-9_-]{1,80}$`)
// IsValidSlackChannel validates a channel name conforms to what slack expects: