fixed kilo in metals 6

This commit is contained in:
2026-06-23 22:05:47 +03:30
parent 1b310b4752
commit 0c46a0a24c
3 changed files with 44 additions and 25 deletions
+40 -14
View File
@@ -73,6 +73,26 @@ class Controller extends BaseController
return $formatted !== '' ? $formatted : '0';
}
/**
* گزینه‌های Guzzle/cURL — فقط وقتی افزونه curl و ثابت‌ها موجود باشند.
*
* @param array<int, mixed> $curlOptions
* @return array<string, array<int, mixed>>
*/
public static function httpClientOptions(array $curlOptions = []): array
{
$curl = $curlOptions;
if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
$resolveOpt = (int) constant('CURLOPT_IPRESOLVE');
if (! array_key_exists($resolveOpt, $curl)) {
$curl[$resolveOpt] = (int) constant('CURL_IPRESOLVE_V4');
}
}
return $curl === [] ? [] : ['curl' => $curl];
}
public static function Send($to , $msg, $is_customer = true)
{
$r = self::SendMessage($to , $msg, $is_customer);
@@ -139,26 +159,32 @@ class Controller extends BaseController
]);
$platforms[] = "0098:{$to}";*/
$response = Http::timeout(15)
->withHeaders([
'Content-Type' => 'application/json',
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
])
->withOptions([
'curl' => [
\CURLOPT_IPRESOLVE => \CURL_IPRESOLVE_V4,
]
])
->post('http://185.231.112.101/api/createsms', [
try {
$http = Http::timeout(15)
->withHeaders([
'Content-Type' => 'application/json',
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
]);
$curlOptions = self::httpClientOptions();
if ($curlOptions !== []) {
$http = $http->withOptions($curlOptions);
}
$response = $http->post('http://185.231.112.101/api/createsms', [
'phone' => $to,
'host' => $config->Config('name_fa') ?? gethostname(),
'text' => trim($msg),
'platform' => 'rayegansms',
]);
$platforms[] = $response->successful()
? "rayegansms:{$to}"
: "rayegansms_failed:{$to}:{$response->status()}";
$platforms[] = $response->successful()
? "rayegansms:{$to}"
: "rayegansms_failed:{$to}:{$response->status()}";
} catch (\Throwable $e) {
report($e);
$platforms[] = "rayegansms_error:{$to}";
}
}
+3 -6
View File
@@ -78,12 +78,9 @@ class MontzarService
$response = Http::timeout(7)
->acceptJson()
->withOptions([
'curl' => [
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
CURLOPT_TCP_FASTOPEN => 1,
],
])
->withOptions(self::httpClientOptions(
defined('CURLOPT_TCP_FASTOPEN') ? [(int) constant('CURLOPT_TCP_FASTOPEN') => 1] : []
))
->withToken($token)
->get($this->endpoint('/server/customer/product/list'))
->json();
+1 -5
View File
@@ -84,11 +84,7 @@ class WebsocketBroadcastService
try {
$response = Http::timeout(3)
->withHeaders(['Content-Type' => 'application/json'])
->withOptions([
'curl' => [
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
],
])
->withOptions(\App\Http\Controllers\Controller::httpClientOptions())
->post($url, $body);
if (! $response->successful()) {