Skip to content

Commit

Permalink
Add verification and forwarding of webhooks for WAC/WA
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed May 4, 2023
1 parent 84d9e0a commit 85cefa4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion handlers/facebookapp/facebookapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,13 @@ func (h *handler) receiveEvent(ctx context.Context, channel courier.Channel, w h
events, data, err = h.processFacebookInstagramPayload(ctx, channel, payload, w, r)
} else {
events, data, err = h.processCloudWhatsAppPayload(ctx, channel, payload, w, r)

webhook := channel.ConfigForKey("webhook", nil)
if webhook != nil {
er := handlers.SendWebhooks(channel, r, webhook)
if er != nil {
return nil, er
}
}
}

if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions handlers/whatsapp/whatsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ func (h *handler) receiveEvent(ctx context.Context, channel courier.Channel, w h
data = append(data, courier.NewStatusData(event))
}

webhook := channel.ConfigForKey("webhook", nil)
if webhook != nil {
err = handlers.SendWebhooks(channel, r, webhook)
if err != nil {
return nil, handlers.WriteAndLogRequestError(ctx, h, channel, w, r, err)
}
}

return events, courier.WriteDataResponse(ctx, w, http.StatusOK, "Events Handled", data)
}

Expand Down

0 comments on commit 85cefa4

Please sign in to comment.