Merge remote-tracking branch 'origin/1.5.x' into feat-rc-sdks

This commit is contained in:
Jake Barnby 2024-02-07 19:14:10 +13:00
commit 982310e7de
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 16 additions and 33 deletions

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()) {
@ -401,7 +398,7 @@ class Messaging extends Action
$credentials['teamId'],
$credentials['bundleId'],
),
'fcm' => new FCM($credentials['serviceAccountJSON']),
'fcm' => new FCM(\json_encode($credentials['serviceAccountJSON'])),
default => null
};
}
@ -466,7 +463,7 @@ class Messaging extends Action
$to = $message['to'];
$subject = $data['subject'];
$content = $data['content'];
$html = $data['html'];
$html = $data['html'] ?? false;
return new Email($to, $subject, $content, $fromName, $fromEmail, $replyToName, $replyToEmail, $cc, $bcc, null, $html);
}
@ -485,13 +482,13 @@ class Messaging extends Action
$to = $message['to'];
$title = $message['data']['title'];
$body = $message['data']['body'];
$data = $message['data']['data'];
$action = $message['data']['action'];
$sound = $message['data']['sound'];
$icon = $message['data']['icon'];
$color = $message['data']['color'];
$tag = $message['data']['tag'];
$badge = $message['data']['badge'];
$data = $message['data']['data'] ?? null;
$action = $message['data']['action'] ?? null;
$sound = $message['data']['sound'] ?? null;
$icon = $message['data']['icon'] ?? null;
$color = $message['data']['color'] ?? null;
$tag = $message['data']['tag'] ?? null;
$badge = $message['data']['badge'] ?? null;
return new Push($to, $title, $body, $data, $action, $sound, $icon, $color, $tag, $badge);
}

View file

@ -99,13 +99,6 @@ class Message extends Model
'description' => 'Status of delivery.',
'default' => 'processing',
'example' => 'Message status can be one of the following: processing, sent, cancelled, failed.',
])
->addRule('description', [
'type' => self::TYPE_STRING,
'description' => 'Message description.',
'required' => false,
'default' => '',
'example' => 'Welcome Email.',
]);
}

View file

@ -39,13 +39,6 @@ class Topic extends Model
'description' => 'Total count of subscribers subscribed to topic.',
'default' => 0,
'example' => 100,
])
->addRule('description', [
'type' => self::TYPE_STRING,
'description' => 'Description of the topic.',
'default' => '',
'required' => false,
'example' => 'All events related messages will be sent to this topic.',
]);
}