Update: 2026-07-09 03:41:48
This commit is contained in:
@@ -77,31 +77,32 @@ try {
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// 2. إشعار السائق (Socket + FCM)
|
||||
// 2. إشعار السائق/السائقين (Socket + FCM)
|
||||
// =================================================================
|
||||
// 🔥 يُرسل دائماً بغض النظر عن driver_id — إذا كانت الرحلة لم تُقبل بعد
|
||||
// (driver_id = 0)، لوكيشن سيرفر يستخدم ride:offered_drivers:{rideId}
|
||||
// من Redis لإشعار كل السائقين الذين وصلهم عرض هذه الرحلة أصلاً.
|
||||
$socketUrl = getenv('LOCATION_SERVER_URL') ?: 'http://location.intaleq.xyz:2021';
|
||||
$internalKeyPath = getenv('INTERNAL_SOCKET_KEY_PATH') ?: '';
|
||||
$internalKey = ($internalKeyPath && file_exists($internalKeyPath)) ? trim(file_get_contents($internalKeyPath)) : (getenv('INTERNAL_SOCKET_KEY') ?: '');
|
||||
|
||||
$ch = curl_init($socketUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
'action' => 'cancel_ride',
|
||||
'driver_id' => $driverId,
|
||||
'ride_id' => $rideId,
|
||||
'reason' => $reason
|
||||
]));
|
||||
if (!empty($internalKey)) curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-internal-key: $internalKey"]);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 500);
|
||||
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
|
||||
@curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($driverId > 0) {
|
||||
|
||||
// أ) Socket (إشعار السائق في التطبيق فوراً)
|
||||
$socketUrl = getenv('LOCATION_SERVER_URL') ?: 'http://location.intaleq.xyz:2021';
|
||||
$internalKeyPath = getenv('INTERNAL_SOCKET_KEY_PATH') ?: '';
|
||||
$internalKey = ($internalKeyPath && file_exists($internalKeyPath)) ? trim(file_get_contents($internalKeyPath)) : (getenv('INTERNAL_SOCKET_KEY') ?: '');
|
||||
|
||||
$ch = curl_init($socketUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||
'action' => 'cancel_ride',
|
||||
'driver_id' => $driverId,
|
||||
'ride_id' => $rideId,
|
||||
'reason' => $reason
|
||||
]));
|
||||
if (!empty($internalKey)) curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-internal-key: $internalKey"]);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 500);
|
||||
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
|
||||
@curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// ب) FCM (باستخدام الدالة الجديدة مع فك التشفير)
|
||||
// FCM للسائق الذي قَبِل الرحلة فعلاً (باستخدام الدالة الجديدة مع فك التشفير)
|
||||
$driverToken = filterRequest("driver_token");
|
||||
|
||||
if (empty($driverToken)) {
|
||||
|
||||
Reference in New Issue
Block a user