mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Query provider type directly for targets
This commit is contained in:
parent
4a71e6ef4f
commit
b862c8ee1e
1 changed files with 4 additions and 4 deletions
|
|
@ -156,14 +156,14 @@ class Messaging extends Action
|
||||||
if (\count($targetIds) > 0) {
|
if (\count($targetIds) > 0) {
|
||||||
$targets = $dbForProject->find('targets', [
|
$targets = $dbForProject->find('targets', [
|
||||||
Query::equal('$id', $targetIds),
|
Query::equal('$id', $targetIds),
|
||||||
|
Query::equal('providerType', [$providerType]),
|
||||||
Query::limit(\count($targetIds)),
|
Query::limit(\count($targetIds)),
|
||||||
]);
|
]);
|
||||||
$targets = \array_filter($targets, fn(Document $target) =>
|
|
||||||
$target->getAttribute('providerType') === $message->getAttribute('providerType'));
|
\array_push($allTargets, ...$targets);
|
||||||
$recipients = \array_merge($recipients, $targets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($recipients)) {
|
if (empty($allTargets)) {
|
||||||
$dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([
|
$dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([
|
||||||
'status' => MessageStatus::FAILED,
|
'status' => MessageStatus::FAILED,
|
||||||
'deliveryErrors' => ['No valid recipients found.']
|
'deliveryErrors' => ['No valid recipients found.']
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue