diff --git a/main.go b/main.go index b90639c..e772a15 100644 --- a/main.go +++ b/main.go @@ -19,13 +19,6 @@ var ( errInvalidSignature = errors.New("invalid signature") ) -// Can't be const because need reference to variable for Slack webhook title -var ( - ClickedLink string = "Clicked Link" - SubmittedData string = "Submitted Data" - EmailOpened string = "Email Opened" -) - func validateSignature(body []byte, r *http.Request) error { secret := viper.GetString("secret") mac := hmac.New(sha256.New, []byte(secret)) @@ -65,6 +58,10 @@ func handler(w http.ResponseWriter, r *http.Request) { return } + if response.Success { + return + } + sender, err := senderDispatch(response.Message, response, []byte(response.Details)) if err != nil { log.Error(err) diff --git a/messages.go b/messages.go index 47134aa..b400709 100644 --- a/messages.go +++ b/messages.go @@ -11,6 +11,13 @@ import ( "github.com/spf13/viper" ) +// Can't be const because need reference to variable for Slack webhook title +var ( + ClickedLink string = "Clicked Link" + SubmittedData string = "Submitted Data" + EmailOpened string = "Email Opened" +) + type Sender interface { SendSlack() error SendEmail() error @@ -33,7 +40,7 @@ func senderDispatch(status string, webhookResponse WebhookResponse, response []b // More information about events can be found here: // https://github.com/gophish/gophish/blob/db63ee978dcd678caee0db71e5e1b91f9f293880/models/result.go#L50 type WebhookResponse struct { - Success string `json:"success"` + Success bool `json:"success"` CampaignID uint `json:"campaign_id"` Message string `json:"message"` Details string `json:"details"`