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

Query provider type directly for targets

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

View file

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