1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00

Fix response iteration

This commit is contained in:
Jake Barnby 2024-02-06 04:11:40 +13:00
parent 47dec4e187
commit 6e40973771
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -232,20 +232,17 @@ class Messaging extends Action
};
try {
$response = new Response($provider->getAttribute('type'));
$response->fromArray($adapter->send($data));
$deliveredTotal += $response->getDeliveredTo();
$details[] = $response->getDetails();
foreach ($details as $detail) {
if ($detail['status'] === 'failure') {
$deliveryErrors[] = "Failed sending to target {$detail['recipient']} with error: {$detail['error']}";
$response = $adapter->send($data);
$deliveredTotal += $response['deliveredTo'];
foreach ($response['results'] as $result) {
if ($result['status'] === 'failure') {
$deliveryErrors[] = "Failed sending to target {$result['recipient']} with error: {$result['error']}";
}
// Deleting push targets when token has expired.
if ($detail['error'] === 'Expired device token.') {
if (($result['error'] ?? '') === 'Expired device token.') {
$target = $dbForProject->findOne('targets', [
Query::equal('identifier', [$detail['recipient']])
Query::equal('identifier', [$result['recipient']])
]);
if ($target instanceof Document && !$target->isEmpty()) {