feat(sms): simplify SMS settings to use only KAVENEGAR_API_KEY from env, remove other SMS-related fields from config

This commit is contained in:
hamed
2026-07-01 11:53:16 +03:30
parent 9d8d1014f1
commit b366baa64c
11 changed files with 352 additions and 92 deletions
+3 -1
View File
@@ -29,6 +29,8 @@ use OpenApi\Attributes as OA;
#[IsGranted('IS_AUTHENTICATED_FULLY')]
class SmsWalletController extends BaseController
{
private const SMS_PRICE_RIALS = 500;
public function __construct(
private readonly SmsWalletService $walletService,
private readonly SmsWalletRepository $walletRepo,
@@ -53,7 +55,7 @@ class SmsWalletController extends BaseController
}
$balanceRials = $this->walletService->getBalance($entityType, $entityId);
$smsPriceRials = (int) ($this->configRepo->get('sms_price_rials') ?? 500);
$smsPriceRials = self::SMS_PRICE_RIALS;
$estimatedSms = $smsPriceRials > 0 ? (int) floor($balanceRials / $smsPriceRials) : 0;
return $this->success([
+3 -6
View File
@@ -2,7 +2,6 @@
namespace App\Sms\Provider;
use App\Config\Repository\SiteConfigRepository;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -12,16 +11,14 @@ class KavehNegarProvider implements SmsProviderInterface
public function __construct(
private readonly HttpClientInterface $httpClient,
private readonly SiteConfigRepository $configRepo,
private readonly LoggerInterface $logger,
// Nullable: env `%env(default::KAVENEGAR_API_KEY)%` resolves to null when unset
// (the real key normally comes from DB site config below, not env).
// API key comes only from env `%env(default::KAVENEGAR_API_KEY)%`; null when unset.
private readonly ?string $apiKey = null,
private readonly ?string $sender = null,
) {}
private function key(): string { return $this->configRepo->get('kavenegar_api_key') ?: ($this->apiKey ?? ''); }
private function sender(): string { return $this->configRepo->get('kavenegar_sender') ?: ($this->sender ?? ''); }
private function key(): string { return $this->apiKey ?? ''; }
private function sender(): string { return $this->sender ?? ''; }
public function getName(): string { return 'kavenegar'; }