From b862c8ee1eb8bb44ff4b730d47f29fa4b8cf459b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 28 Feb 2024 00:56:23 +1300 Subject: [PATCH] Query provider type directly for targets --- src/Appwrite/Platform/Workers/Messaging.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index ae7fcba69e..e4710461ca 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -156,14 +156,14 @@ class Messaging extends Action if (\count($targetIds) > 0) { $targets = $dbForProject->find('targets', [ Query::equal('$id', $targetIds), + Query::equal('providerType', [$providerType]), Query::limit(\count($targetIds)), ]); - $targets = \array_filter($targets, fn(Document $target) => - $target->getAttribute('providerType') === $message->getAttribute('providerType')); - $recipients = \array_merge($recipients, $targets); + + \array_push($allTargets, ...$targets); } - if (empty($recipients)) { + if (empty($allTargets)) { $dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([ 'status' => MessageStatus::FAILED, 'deliveryErrors' => ['No valid recipients found.']