1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00

Remove redundant checks

This commit is contained in:
Jake Barnby 2024-02-28 00:56:52 +13:00
parent b862c8ee1e
commit e1e9fc6589
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -173,18 +173,18 @@ class Messaging extends Action
return;
}
$fallback = $dbForProject->findOne('providers', [
$default = $dbForProject->findOne('providers', [
Query::equal('enabled', [true]),
Query::equal('type', [$recipients[0]->getAttribute('providerType')]),
Query::equal('type', [$providerType]),
]);
if ($fallback === false || $fallback->isEmpty()) {
if ($default === false || $default->isEmpty()) {
$dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([
'status' => MessageStatus::FAILED,
'deliveryErrors' => ['No fallback provider found.']
'deliveryErrors' => ['No enabled provider found.']
]));
Console::warning('No fallback provider found.');
Console::warning('No enabled provider found.');
return;
}
@ -194,22 +194,17 @@ class Messaging extends Action
$identifiers = [];
/**
* @var Document[] $providers
* @var array<Document> $providers
*/
$providers = [
$fallback->getId() => $fallback
$default->getId() => $default
];
foreach ($recipients as $recipient) {
$providerId = $recipient->getAttribute('providerId');
foreach ($allTargets as $target) {
$providerId = $target->getAttribute('providerId');
if (
!$providerId
&& $fallback instanceof Document
&& !$fallback->isEmpty()
&& $fallback->getAttribute('enabled')
) {
$providerId = $fallback->getId();
if (!$providerId) {
$providerId = $default->getId();
}
if ($providerId) {