Skip to content

Commit

Permalink
Fix issue on Ping
Browse files Browse the repository at this point in the history
  • Loading branch information
t94j0 committed Aug 16, 2021
1 parent 55ba1b9 commit 5441eeb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 4 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"`
Expand Down

0 comments on commit 5441eeb

Please sign in to comment.