Remove legacy ShortMessage components and integrate Notifier

Replaced outdated ShortMessage functionalities with Symfony's Notifier component for handling SMS messages. Deprecated legacy `ShortMessage` components and introduced a transition layer for existing OVH configurations. Updated dependencies and environment setup to support the new implementation.
This commit is contained in:
2025-01-17 17:13:36 +01:00
parent b02820407c
commit 5e3a1eb2ab
17 changed files with 134 additions and 263 deletions

View File

@@ -1,24 +0,0 @@
<?php
/**
* 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.
*/
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\ShortMessage;
class NullShortMessageSender implements ShortMessageSenderInterface
{
public function send(ShortMessage $shortMessage): void {}
}

View File

@@ -20,6 +20,8 @@ namespace Chill\MainBundle\Service\ShortMessage;
use libphonenumber\PhoneNumber;
trigger_deprecation('chill-project/chill-bundles', '3.7', 'Short Messages are deprecated, use SmsMessage and Notifier component instead');
class ShortMessage
{
final public const PRIORITY_LOW = 'low';

View File

@@ -18,17 +18,33 @@ declare(strict_types=1);
namespace Chill\MainBundle\Service\ShortMessage;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
use Symfony\Component\Notifier\Message\SmsMessage;
use Symfony\Component\Notifier\TexterInterface;
/**
* @AsMessageHandler
*/
class ShortMessageHandler implements MessageHandlerInterface
{
public function __construct(private readonly ShortMessageTransporterInterface $messageTransporter) {}
private readonly PhoneNumberUtil $phoneNumberUtil;
public function __construct(private readonly TexterInterface $texter)
{
$this->phoneNumberUtil = PhoneNumberUtil::getInstance();
}
public function __invoke(ShortMessage $message): void
{
$this->messageTransporter->send($message);
trigger_deprecation('Chill-project/chill-bundles', '3.7.0', 'Send message using Notifier component');
$this->texter->send(
new SmsMessage(
$this->phoneNumberUtil->format($message->getPhoneNumber(), PhoneNumberFormat::E164),
$message->getContent(),
),
);
}
}

View File

@@ -1,24 +0,0 @@
<?php
/**
* 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.
*/
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\ShortMessage;
interface ShortMessageSenderInterface
{
public function send(ShortMessage $shortMessage): void;
}

View File

@@ -1,29 +0,0 @@
<?php
/**
* 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.
*/
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\ShortMessage;
class ShortMessageTransporter implements ShortMessageTransporterInterface
{
public function __construct(private readonly ShortMessageSenderInterface $sender) {}
public function send(ShortMessage $shortMessage): void
{
$this->sender->send($shortMessage);
}
}

View File

@@ -1,24 +0,0 @@
<?php
/**
* 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.
*/
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\ShortMessage;
interface ShortMessageTransporterInterface
{
public function send(ShortMessage $shortMessage);
}