11<?php
22
3- namespace Vormkracht10 \Mails \Drivers ;
3+ namespace Backstage \Mails \Drivers ;
44
55use Backstage \Mails \Contracts \MailDriverContract ;
6- use Backstage \Mails \Drivers \MailDriver ;
76use Backstage \Mails \Enums \EventType ;
87use Illuminate \Mail \Events \MessageSending ;
98
@@ -22,7 +21,9 @@ public function verifyWebhookSignature(array $payload): bool
2221
2322 public function getUuidFromPayload (array $ payload ): ?string
2423 {
25- return $ payload ['data ' ]['email_id ' ];
24+ return collect ($ payload ['data ' ]['headers ' ])
25+ ->where ('name ' , config ('mails.headers.uuid ' ))
26+ ->first ()['value ' ] ?? null ;
2627 }
2728
2829 protected function getTimestampFromPayload (array $ payload ): string
@@ -32,15 +33,13 @@ protected function getTimestampFromPayload(array $payload): string
3233
3334 public function eventMapping (): array
3435 {
35-
3636 return [
3737 EventType::CLICKED ->value => ['type ' => 'email.clicked ' ],
3838 EventType::COMPLAINED ->value => ['type ' => 'email.complained ' ],
3939 EventType::DELIVERED ->value => ['type ' => 'email.delivered ' ],
4040 EventType::HARD_BOUNCED ->value => ['type ' => 'email.bounced ' ],
4141 EventType::OPENED ->value => ['type ' => 'email.opened ' ],
4242 EventType::SOFT_BOUNCED ->value => ['type ' => 'email.delivery_delayed ' ],
43- EventType::UNSUBSCRIBED ->value => ['type ' => 'SubscriptionChange ' ],
4443 ];
4544 }
4645
@@ -55,7 +54,7 @@ public function dataMapping(): array
5554
5655 public function attachUuidToMail (MessageSending $ event , string $ uuid ): MessageSending
5756 {
58- $ event ->message ->getHeaders ()->addTextHeader (' X-Resend-Metadata- ' . config ('mails.headers.uuid ' ), $ uuid );
57+ $ event ->message ->getHeaders ()->addTextHeader (config ('mails.headers.uuid ' ), $ uuid );
5958
6059 return $ event ;
6160 }
0 commit comments