From: Louis Jeckel Date: Mon, 7 Sep 2020 07:48:06 +0000 (+0200) Subject: Update DispatchMailgunEvent.php X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f6f55d66141244e94caa3714add128571d5826c5;p=psq.git Update DispatchMailgunEvent.php --- diff --git a/app/Events/DispatchMailgunEvent.php b/app/Events/DispatchMailgunEvent.php index 93c5f35..168ec07 100644 --- a/app/Events/DispatchMailgunEvent.php +++ b/app/Events/DispatchMailgunEvent.php @@ -39,22 +39,23 @@ class DispatchMailgunEvent implements ShouldBroadcast $tags = Arr::get($webhookData, 'event-data.tags'); + + /** @todo check webhook key */ $this->batch_id = Str::after(Arr::first($tags, function($tag) { return Str::startsWith($tag, 'batch_id_'); }), 'batch_id_'); + \Log::info('batch ' . $this->batch_id); + $event = MailgunEvent::updateOrCreate([ 'event' => Arr::get($webhookData, 'event-data.event'), 'recipient' => Arr::get($webhookData, 'event-data.recipient'), 'email_batch_id' => $this->batch_id ]); - $this->broadcast = in_array(config('app.env'), $tags, true) && - ($event->wasRecentlyCreated); - - \Log::info("broadcast : " . ($this->broadcast ? "yes" : "no") . " " . config('app.env') . ' | ' . implode(',', $tags) . " | " ); + $this->broadcast = ($event->wasRecentlyCreated); $event->touch();