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.']