mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	Add log SMS when a message is sent
Introduced a new event subscriber to log SMS sent events with details such as recipient and message IDs. This enhances monitoring and debugging of SMS delivery.
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| framework: | ||||
|     notifier: | ||||
|         texter_transports: | ||||
|             #ovhcloud: '%env(OVHCLOUD_DSN)%' | ||||
|             ovhcloud: '%env(SHORT_MESSAGE_DSN)%' | ||||
|         channel_policy: | ||||
|             # use chat/slack, chat/telegram, sms/twilio or sms/nexmo | ||||
|   | ||||
| @@ -0,0 +1,37 @@ | ||||
| <?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(); | ||||
|  | ||||
|         $this->logger->warning('[sms] a sms was sent', ['validReceiversI' => $message->getOriginalMessage()->getRecipientId(), 'idsI' => $message->getMessageId()]); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user