diff --git a/app/Jobs/Ses/DeliveryJob.php b/app/Jobs/Ses/DeliveryJob.php new file mode 100644 index 0000000..6ebb4ce --- /dev/null +++ b/app/Jobs/Ses/DeliveryJob.php @@ -0,0 +1,63 @@ +webhookCall->payload['Message']; + + $campaignId = null; + $subscriberId = null; + + foreach ($message['mail']['headers'] as $header) { + if ($header['name'] === 'Campaign-Id') { + $campaignId = $header['value']; + break; + } + } + + foreach ($message['mail']['headers'] as $header) { + if ($header['name'] === 'Subscriber-Id') { + $subscriberId = $header['value']; + break; + } + } + + $campaignLog = CampaignEmail::query() + ->with('subscriber') + ->where('campaign_id', $campaignId) + ->where('subscriber_id', $subscriberId) + ->first(); + + if ($campaignLog) { + $campaignLog->status = CampaignLogStatusType::DELIVERED->value; + $campaignLog->delivered_at = Carbon::parse($message['mail']['timestamp']); + $campaignLog->save(); + } + } +}