feat: MailJet list handling with DOI, webhook receiver and API endpoint

addresses #869cut134
This commit is contained in:
Björn Fromme committed 2026-04-29 09:51:57 +02:00
1 parent df7885ca1c
commit e4ef2f7adc
46 files changed
+3389 -322

No files matched your search

@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\NewsletterOptInRequest;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<NewsletterOptInRequest>
*/
class NewsletterOptInRequestRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, NewsletterOptInRequest::class);
}
public function findByTokenHash(string $tokenHash): ?NewsletterOptInRequest
{
return $this->findOneBy(['tokenHash' => $tokenHash]);
}
public function findPendingByEmail(string $email): ?NewsletterOptInRequest
{
return $this->createQueryBuilder('c')
->where('c.email = :email')
->andWhere('c.confirmedAt IS NULL')
->andWhere('c.expiresAt > :now')
->setParameter('email', mb_strtolower(trim($email)))
->setParameter('now', new \DateTimeImmutable())
->orderBy('c.createdAt', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
}
public function deleteExpiredPendingByEmail(string $email): int
{
return (int) $this->createQueryBuilder('c')
->delete()
->where('c.email = :email')
->andWhere('c.confirmedAt IS NULL')
->andWhere('c.expiresAt <= :now')
->setParameter('email', mb_strtolower(trim($email)))
->setParameter('now', new \DateTimeImmutable())
->getQuery()
->execute();
}
public function deletePendingByEmail(string $email): int
{
return (int) $this->createQueryBuilder('c')
->delete()
->where('c.email = :email')
->andWhere('c.confirmedAt IS NULL')
->setParameter('email', mb_strtolower(trim($email)))
->getQuery()
->execute();
}
public function deleteExpiredPending(): int
{
$threshold = new \DateTimeImmutable();
return (int) $this->createQueryBuilder('c')
->delete()
->where('c.confirmedAt IS NULL')
->andWhere('c.expiresAt <= :threshold')
->setParameter('threshold', $threshold)
->getQuery()
->execute();
}
}