From 37e16cd93c9c26cda23bd3cd90636fbb126cb6fc Mon Sep 17 00:00:00 2001 From: Pete Hinchcliffe Date: Wed, 18 Jul 2018 08:13:39 +0100 Subject: [PATCH] Swap out old example handler for help handler This commit removes the DialogTest handler that was used for testing. main.go now uses the HelpRequest handler when '/slack/command/help' is hit. --- handlers/handlers.go | 35 ++--------------------------------- main.go | 2 +- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/handlers/handlers.go b/handlers/handlers.go index 1458c31..47bd099 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -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 { @@ -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 -} diff --git a/main.go b/main.go index b698366..6d98a8b 100644 --- a/main.go +++ b/main.go @@ -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 {