fixed kilo in metals 6
This commit is contained in:
@@ -73,6 +73,26 @@ class Controller extends BaseController
|
|||||||
return $formatted !== '' ? $formatted : '0';
|
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)
|
public static function Send($to , $msg, $is_customer = true)
|
||||||
{
|
{
|
||||||
$r = self::SendMessage($to , $msg, $is_customer);
|
$r = self::SendMessage($to , $msg, $is_customer);
|
||||||
@@ -139,26 +159,32 @@ class Controller extends BaseController
|
|||||||
]);
|
]);
|
||||||
$platforms[] = "0098:{$to}";*/
|
$platforms[] = "0098:{$to}";*/
|
||||||
|
|
||||||
$response = Http::timeout(15)
|
try {
|
||||||
->withHeaders([
|
$http = Http::timeout(15)
|
||||||
'Content-Type' => 'application/json',
|
->withHeaders([
|
||||||
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
|
'Content-Type' => 'application/json',
|
||||||
])
|
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
|
||||||
->withOptions([
|
]);
|
||||||
'curl' => [
|
|
||||||
\CURLOPT_IPRESOLVE => \CURL_IPRESOLVE_V4,
|
$curlOptions = self::httpClientOptions();
|
||||||
]
|
if ($curlOptions !== []) {
|
||||||
])
|
$http = $http->withOptions($curlOptions);
|
||||||
->post('http://185.231.112.101/api/createsms', [
|
}
|
||||||
|
|
||||||
|
$response = $http->post('http://185.231.112.101/api/createsms', [
|
||||||
'phone' => $to,
|
'phone' => $to,
|
||||||
'host' => $config->Config('name_fa') ?? gethostname(),
|
'host' => $config->Config('name_fa') ?? gethostname(),
|
||||||
'text' => trim($msg),
|
'text' => trim($msg),
|
||||||
'platform' => 'rayegansms',
|
'platform' => 'rayegansms',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$platforms[] = $response->successful()
|
$platforms[] = $response->successful()
|
||||||
? "rayegansms:{$to}"
|
? "rayegansms:{$to}"
|
||||||
: "rayegansms_failed:{$to}:{$response->status()}";
|
: "rayegansms_failed:{$to}:{$response->status()}";
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
report($e);
|
||||||
|
$platforms[] = "rayegansms_error:{$to}";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,12 +78,9 @@ class MontzarService
|
|||||||
|
|
||||||
$response = Http::timeout(7)
|
$response = Http::timeout(7)
|
||||||
->acceptJson()
|
->acceptJson()
|
||||||
->withOptions([
|
->withOptions(self::httpClientOptions(
|
||||||
'curl' => [
|
defined('CURLOPT_TCP_FASTOPEN') ? [(int) constant('CURLOPT_TCP_FASTOPEN') => 1] : []
|
||||||
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
|
))
|
||||||
CURLOPT_TCP_FASTOPEN => 1,
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->withToken($token)
|
->withToken($token)
|
||||||
->get($this->endpoint('/server/customer/product/list'))
|
->get($this->endpoint('/server/customer/product/list'))
|
||||||
->json();
|
->json();
|
||||||
|
|||||||
@@ -84,11 +84,7 @@ class WebsocketBroadcastService
|
|||||||
try {
|
try {
|
||||||
$response = Http::timeout(3)
|
$response = Http::timeout(3)
|
||||||
->withHeaders(['Content-Type' => 'application/json'])
|
->withHeaders(['Content-Type' => 'application/json'])
|
||||||
->withOptions([
|
->withOptions(\App\Http\Controllers\Controller::httpClientOptions())
|
||||||
'curl' => [
|
|
||||||
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->post($url, $body);
|
->post($url, $body);
|
||||||
|
|
||||||
if (! $response->successful()) {
|
if (! $response->successful()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user