From b98b3389a74830f15d4bdae2e83cfc120c69311b Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 30 Jan 2016 17:46:20 -0800 Subject: [PATCH 1/5] update readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b413e7..6244bc0 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,16 @@ post('mandrill-webhook', ['as' => 'mandrill.webhook', 'uses' => 'MandrillControl 3) Make sure you add your webhook in Mandrill to point to your route. You can do this here: https://mandrillapp.com/settings/webhooks ## Webhook Authentication -Publish the configuration via +Firs, add the EventHomes\Api\Webhooks\MandrillWebhookServiceProvider provider to the providers array in config/app.php + +```php +'providers' => [ + ... + EventHomes\Api\Webhooks\MandrillWebhookServiceProvider::class, +], +``` + +Next, publish the configuration via ```php php artisan vendor:publish --provider="EventHomes\Api\Webhooks\MandrillWebhookServiceProvider" ``` From f76034c39c61764570714045ae6eb8e8bc95ed83 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 30 Jan 2016 17:47:23 -0800 Subject: [PATCH 2/5] typo, simplify --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6244bc0..712d3c9 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ post('mandrill-webhook', ['as' => 'mandrill.webhook', 'uses' => 'MandrillControl 3) Make sure you add your webhook in Mandrill to point to your route. You can do this here: https://mandrillapp.com/settings/webhooks ## Webhook Authentication -Firs, add the EventHomes\Api\Webhooks\MandrillWebhookServiceProvider provider to the providers array in config/app.php +First, add the *MandrillWebhookServiceProvider* provider to the providers array in config/app.php ```php 'providers' => [ From 7c5c9677f1e990eb1a419cd194ee4ccb976d976e Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 30 Jan 2016 18:02:20 -0800 Subject: [PATCH 3/5] add optional note --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 712d3c9..2224a20 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ post('mandrill-webhook', ['as' => 'mandrill.webhook', 'uses' => 'MandrillControl 3) Make sure you add your webhook in Mandrill to point to your route. You can do this here: https://mandrillapp.com/settings/webhooks -## Webhook Authentication -First, add the *MandrillWebhookServiceProvider* provider to the providers array in config/app.php +## (Optional) Webhook Authentication +If you would like to increase the security of the webhooks. Add the *MandrillWebhookServiceProvider* provider to the providers array in config/app.php ```php 'providers' => [ From a9b946a1de32b0beda73a15f5c58069d48cabc7a Mon Sep 17 00:00:00 2001 From: jeroenlammerts Date: Thu, 9 Feb 2017 16:28:56 +0100 Subject: [PATCH 4/5] fix to support blacklist and whitelist methods https://mandrill.zendesk.com/hc/en-us/articles/205583297-Sync-Event-Webhook-format --- src/MandrillWebhookController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MandrillWebhookController.php b/src/MandrillWebhookController.php index 4fd8528..f363e26 100644 --- a/src/MandrillWebhookController.php +++ b/src/MandrillWebhookController.php @@ -21,7 +21,7 @@ public function handleWebHook(Request $request) $events = $this->getJsonPayloadFromRequest($request); foreach ($events as $event) { - $eventName = isset($event['event']) ? $event['event'] : 'undefined'; + $eventName = isset($event['event']) ? $event['event'] : isset($event['type']) ? $event['type'] : 'undefined'; $method = 'handle' . studly_case(str_replace('.', '_', $eventName)); if (method_exists($this, $method)) { From bb99e839b31a67546ed355b4f921a3229e2e5014 Mon Sep 17 00:00:00 2001 From: jeroenlammerts Date: Fri, 10 Feb 2017 12:31:10 +0100 Subject: [PATCH 5/5] fix undefined index, more readable --- src/MandrillWebhookController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MandrillWebhookController.php b/src/MandrillWebhookController.php index f363e26..a0a85a8 100644 --- a/src/MandrillWebhookController.php +++ b/src/MandrillWebhookController.php @@ -21,7 +21,10 @@ public function handleWebHook(Request $request) $events = $this->getJsonPayloadFromRequest($request); foreach ($events as $event) { - $eventName = isset($event['event']) ? $event['event'] : isset($event['type']) ? $event['type'] : 'undefined'; + $eventName = isset($event['event']) ? $event['event'] : 'undefined'; + if($eventName == 'undefined' && isset($event['type'])){ + $eventName = $event['type']; + } $method = 'handle' . studly_case(str_replace('.', '_', $eventName)); if (method_exists($this, $method)) {