Initial commit: CloudOps infrastructure platform

This commit is contained in:
root
2026-04-09 19:58:57 +02:00
commit 1166a52f26
7762 changed files with 839452 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Exception;
class BatchQueueMaxException extends \Exception
{
public function __construct(string $message = 'Max number of emails have been queued. Run flushQueue() first then queue() again', int $code = 0, ?\Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
}

View File

@@ -0,0 +1,73 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Message;
use Symfony\Component\Mime\Email;
class MauticMessage extends Email
{
/**
* @var array<string, array<string, mixed[]>>
*/
protected $metadata = [];
protected ?string $leadIdHash = null;
/**
* @param array<string, string> $metadata
*/
public function addMetadata(string $email, array $metadata): void
{
$this->metadata[$email] = $metadata;
}
/**
* @return array<string, array<string, mixed[]>>
*/
public function getMetadata(): array
{
return $this->metadata;
}
/**
* Clears the metadata.
*/
public function clearMetadata(): void
{
$this->metadata = [];
}
public function updateLeadIdHash(?string $hash): void
{
$this->leadIdHash = $hash;
}
public function getLeadIdHash(): ?string
{
return $this->leadIdHash;
}
/**
* @return array<mixed>
*/
public function __serialize(): array
{
if (empty($this->leadIdHash)) {
$this->leadIdHash = '';
}
return [$this->metadata, $this->leadIdHash, parent::__serialize()];
}
/**
* @param array<mixed> $data
*/
public function __unserialize(array $data): void
{
[$this->metadata, $this->leadIdHash, $parentData] = $data;
parent::__unserialize($parentData);
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Transport;
use Mautic\EmailBundle\MonitoredEmail\Exception\BounceNotFound;
use Mautic\EmailBundle\MonitoredEmail\Message;
use Mautic\EmailBundle\MonitoredEmail\Processor\Bounce\BouncedEmail;
/**
* Interface InterfaceBounceProcessor.
*/
interface BounceProcessorInterface
{
/**
* Get the email address that bounced.
*
* @throws BounceNotFound
*/
public function processBounce(Message $message): BouncedEmail;
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Transport;
use Symfony\Component\Mailer\Envelope;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Component\Mailer\SentMessage;
use Symfony\Component\Mailer\Transport\TransportInterface;
use Symfony\Component\Mime\RawMessage;
class InvalidTransport implements TransportInterface
{
public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMessage
{
throw new TransportException('Unknown DSN scheme. Please make sure the mailer DSN is configured properly.');
}
public function __toString(): string
{
return 'invalid://';
}
}

View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Transport;
use Symfony\Component\Mime\Email;
interface TokenTransportInterface
{
/**
* Return the max number of to addresses allowed per batch. If there is no limit, return 0.
*/
public function getMaxBatchLimit(): int;
/**
* Get the count for the max number of recipients per batch.
*
* @param int $toBeAdded Number of emails about to be added
* @param string $type Type of emails being added (to, cc, bcc)
*/
public function getBatchRecipientCount(Email $message, int $toBeAdded = 1, string $type = 'to'): int;
}

View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Transport;
use Symfony\Component\Mime\Email;
trait TokenTransportTrait
{
public function getBatchRecipientCount(Email $message, int $toBeAdded = 1, string $type = 'to'): int
{
return count($message->getTo()) + count($message->getCc()) + count($message->getBcc()) + $toBeAdded;
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Transport;
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
use Symfony\Component\Mailer\Transport as SymfonyTransportFactory;
use Symfony\Component\Mailer\Transport\Dsn;
use Symfony\Component\Mailer\Transport\TransportInterface;
use Symfony\Component\Mailer\Transport\Transports;
class TransportFactory
{
public function __construct(
private SymfonyTransportFactory $transportFactory,
) {
}
/**
* @param array<string, string> $dsns
*/
public function fromStrings(array $dsns): Transports
{
$transports = [];
foreach ($dsns as $name => $dsn) {
$transports[$name] = $this->fromString($dsn);
}
return new Transports($transports);
}
public function fromString(string $dsn): TransportInterface
{
try {
return $this->transportFactory->fromString($dsn);
} catch (UnsupportedSchemeException) {
return new InvalidTransport();
}
}
public function fromDsnObject(Dsn $dsn): TransportInterface
{
return $this->transportFactory->fromDsnObject($dsn);
}
}

View File

@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Mailer\Transport;
use Mautic\EmailBundle\MonitoredEmail\Exception\UnsubscriptionNotFound;
use Mautic\EmailBundle\MonitoredEmail\Message;
use Mautic\EmailBundle\MonitoredEmail\Processor\Unsubscription\UnsubscribedEmail;
/**
* Interface InterfaceUnsubscriptionProcessor.
*/
interface UnsubscriptionProcessorInterface
{
/**
* Get the email address that unsubscribed.
*
* @throws UnsubscriptionNotFound
*/
public function processUnsubscription(Message $message): UnsubscribedEmail;
}