mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-06 12:18:24 +00:00
Added a condition to log an info message when the sent SMS lacks a message ID. Ensures clearer distinction between successful and incomplete SMS message logging.
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Service\Notifier;
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
use Symfony\Component\Notifier\Event\SentMessageEvent;
|
|
|
|
final readonly class SentMessageEventSubscriber implements EventSubscriberInterface
|
|
{
|
|
public function __construct(
|
|
private LoggerInterface $logger,
|
|
) {}
|
|
|
|
public static function getSubscribedEvents()
|
|
{
|
|
return [
|
|
SentMessageEvent::class => ['onSentMessage', 0],
|
|
];
|
|
}
|
|
|
|
public function onSentMessage(SentMessageEvent $event): void
|
|
{
|
|
$message = $event->getMessage();
|
|
|
|
if (null === $message->getMessageId()) {
|
|
$this->logger->info('[sms] a sms message did not had any id after sending.', ['validReceiversI' => $message->getOriginalMessage()->getRecipientId()]);
|
|
} else {
|
|
$this->logger->warning('[sms] a sms was sent', ['validReceiversI' => $message->getOriginalMessage()->getRecipientId(), 'idsI' => $message->getMessageId()]);
|
|
}
|
|
}
|
|
}
|