PHRAS-3598 Webhook - Emit improvement - Count and Log errors - stop to notify endpoint in error (#4209)

* deactivate webhook when many times undelivered

* fix

* fix log
This commit is contained in:
Aina Sitraka
2023-01-11 16:52:22 +03:00
committed by GitHub
parent 232224373d
commit fc278420a4
3 changed files with 50 additions and 4 deletions

View File

@@ -23,7 +23,6 @@ use Doctrine\ORM\EntityRepository;
*/
class WebhookEventDeliveryRepository extends EntityRepository
{
/**
* @return WebhookEventDelivery[]
*/
@@ -40,6 +39,26 @@ class WebhookEventDeliveryRepository extends EntityRepository
return $qb->getQuery()->getResult();
}
/**
* @param $apiApplication
* @return WebhookEventDelivery[]
*/
public function findUndeliveredEventsFromLastAppUpdate(ApiApplication $apiApplication)
{
$qb = $this->createQueryBuilder('e');
$qb
->join('e.application', 'a')
->where('e.application = :app')
->andWhere($qb->expr()->eq('e.delivered', $qb->expr()->literal(false)))
->andWhere('e.deliveryTries = 3')
->andWhere('e.created > a.updated')
->setParameter(':app', $apiApplication)
;
return $qb->getQuery()->getResult();
}
/**
* @param ApiApplication $apiApplication
* @param int $count