Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Commit

Permalink
Fix included
Browse files Browse the repository at this point in the history
  • Loading branch information
Caiyeon committed Aug 26, 2017
1 parent 830a65e commit 132e2b5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion handlers/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"strings"

"github.com/caiyeon/goldfish/request"
"github.com/caiyeon/goldfish/slack"
"github.com/caiyeon/goldfish/vault"
"github.com/labstack/echo"
)

Expand Down Expand Up @@ -84,7 +86,24 @@ func AddRequest() echo.HandlerFunc {
}
}

// TODO: add slack webhook
// if config has a slack webhook, send the hash (aka change ID) to the channel
conf := vault.GetConfig()
if conf.SlackWebhook != "" {
// send a message using webhook
err = slack.PostMessageWebhook(
conf.SlackChannel,
"A new policy change request has been submitted",
"Request ID: \n*"+hash+"*",
conf.SlackWebhook,
)
// change request is fine, just let the frontend know it wasn't slack'd
if err != nil {
return c.JSON(http.StatusOK, H{
"result": hash,
"error": "Could not send to slack webhook",
})
}
}

// if all is good, return hash
return c.JSON(http.StatusOK, H{
Expand Down

0 comments on commit 132e2b5

Please sign in to comment.