File tree 2 files changed +24
-1
lines changed
src/Symfony/Component/Mailer/Bridge/Sendgrid
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,14 @@ public function convert(array $payload): AbstractMailerEvent
51
51
$ event ->setDate ($ date );
52
52
$ event ->setRecipientEmail ($ payload ['email ' ]);
53
53
$ event ->setMetadata ([]);
54
- $ event ->setTags ($ payload ['category ' ] ?? []);
54
+
55
+ $ tags = [];
56
+ // If you send single categories as an array, they will be returned by the webhook as an array.
57
+ // If you send single categories as a string, they will be returned by the webhook as a string.
58
+ if (isset ($ payload ['category ' ])) {
59
+ $ tags = \is_array ($ payload ['category ' ]) ? $ payload ['category ' ] : [$ payload ['category ' ]];
60
+ }
61
+ $ event ->setTags ($ tags );
55
62
56
63
return $ event ;
57
64
}
Original file line number Diff line number Diff line change @@ -97,4 +97,20 @@ public function testInvalidDate()
97
97
'email ' => 'test@example.com ' ,
98
98
]);
99
99
}
100
+
101
+ public function testWithStringCategory ()
102
+ {
103
+ $ converter = new SendgridPayloadConverter ();
104
+
105
+ $ event = $ converter ->convert ([
106
+ 'event ' => 'processed ' ,
107
+ 'sg_message_id ' => '123456 ' ,
108
+ 'timestamp ' => '123456789 ' ,
109
+ 'email ' => 'test@example.com ' ,
110
+ 'category ' => 'cat facts ' ,
111
+ ]);
112
+
113
+ $ this ->assertInstanceOf (MailerDeliveryEvent::class, $ event );
114
+ $ this ->assertSame (['cat facts ' ], $ event ->getTags ());
115
+ }
100
116
}
You can’t perform that action at this time.
0 commit comments