Skip to content

Commit

Permalink
Swap out old example handler for help handler
Browse files Browse the repository at this point in the history
This commit removes the DialogTest handler that was used for testing.
main.go now uses the HelpRequest handler when '/slack/command/help' is
hit.
  • Loading branch information
iwishiwerearobot committed Jul 18, 2018
1 parent 2478cb2 commit 37e16cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 34 deletions.
35 changes: 2 additions & 33 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/skybet/go-helpdesk/wrapper"
)

// HelpRequest is a handler that creates a dialog in Slack to capture a
// customers help request
func HelpRequest(w http.ResponseWriter, r *http.Request) error {
sc, err := slack.SlashCommandParse(r)
if err != nil {
Expand Down Expand Up @@ -38,36 +40,3 @@ func HelpRequest(w http.ResponseWriter, r *http.Request) error {
}
return nil
}

// DialogTest is a simple test handler to create a dialog in Slack
func DialogTest(w http.ResponseWriter, r *http.Request) error {
//get_the_formatted_request and from it get the trigger id
sc, err := slack.SlashCommandParse(r)
if err != nil {
return fmt.Errorf("Failed to parse slack slash command: %s", err)
}

descElement := slack.DialogTextElement{
Type: "text",
Label: "Description",
Placeholder: "Description...",
Name: "FOO",
}

elements := []slack.DialogElement{
descElement,
}

dialog := slack.Dialog{
CallbackId: "PETETEST",
Title: "Create an Incident",
SubmitLabel: "Create",
NotifyOnCancel: true,
Elements: elements,
}

if err := wrapper.OpenDialog(sc.TriggerID, dialog); err != nil {
return fmt.Errorf("Failed to open dialog: %s", err)
}
return nil
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
s := server.NewSlackReceiver()
r := &server.Route{
Path: "/slack/command/help",
Handler: handlers.DialogTest,
Handler: handlers.HelpRequest,
}

if err := s.AddRoute(r); err != nil {
Expand Down

0 comments on commit 37e16cd

Please sign in to comment.