From 97907bde94ae3dc0669d90d081a41acacf56ccd1 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 29 May 2026 00:49:58 +0300 Subject: [PATCH] add new features like realtime 2026-05-29-00 --- ride/call/driver/create_call_session.php | 19 ++++++++++--------- ride/call/passenger/create_call_session.php | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ride/call/driver/create_call_session.php b/ride/call/driver/create_call_session.php index b340581..ee588a1 100644 --- a/ride/call/driver/create_call_session.php +++ b/ride/call/driver/create_call_session.php @@ -8,13 +8,13 @@ declare(strict_types=1); -require_once __DIR__ . '/../../bootstrap/init.php'; -require_once __DIR__ . '/../../core/Auth.php'; -require_once __DIR__ . '/../../core/Response.php'; -require_once __DIR__ . '/../../core/FCM.php'; +require_once __DIR__ . '/../../../connect.php'; try { - $jwt = authenticateJWT('driver'); + if ($role !== 'driver' || empty($user_id)) { + printFailure('Unauthorized access'); + exit; + } $rideId = $_POST['ride_id'] ?? null; if (!$rideId) { @@ -30,7 +30,7 @@ try { WHERE r.id = :rid AND r.driver_id = :did AND r.status IN ('accepted', 'arrived', 'started', 'begin') LIMIT 1 "); - $stmt->execute([':rid' => $rideId, ':did' => $jwt->user_id]); + $stmt->execute([':rid' => $rideId, ':did' => $user_id]); $ride = $stmt->fetch(); if (!$ride) { @@ -48,7 +48,7 @@ try { $ch = curl_init($url); $payload = json_encode([ 'ride_id' => (string)$rideId, - 'driver_id' => (string)$jwt->user_id, + 'driver_id' => (string)$user_id, 'passenger_id' => (string)$passengerId ]); @@ -94,7 +94,7 @@ try { $passengerTokenRow = $stmtToken->fetch(); if ($passengerTokenRow && !empty($passengerTokenRow['token'])) { - sendFCMData( + sendFcmNotification( $passengerTokenRow['token'], 'Incoming Call', 'Incoming WebRTC voice call', @@ -105,7 +105,8 @@ try { 'caller_avatar' => '', 'ride_id' => (string)$rideId ], - 'Call' + 'Call', + 'ding' ); } diff --git a/ride/call/passenger/create_call_session.php b/ride/call/passenger/create_call_session.php index a880798..c16ecd3 100644 --- a/ride/call/passenger/create_call_session.php +++ b/ride/call/passenger/create_call_session.php @@ -8,13 +8,13 @@ declare(strict_types=1); -require_once __DIR__ . '/../../bootstrap/init.php'; -require_once __DIR__ . '/../../core/Auth.php'; -require_once __DIR__ . '/../../core/Response.php'; -require_once __DIR__ . '/../../core/FCM.php'; +require_once __DIR__ . '/../../../connect.php'; try { - $jwt = authenticateJWT('passenger'); + if ($role !== 'passenger' || empty($user_id)) { + printFailure('Unauthorized access'); + exit; + } $rideId = $_POST['ride_id'] ?? null; if (!$rideId) { @@ -30,7 +30,7 @@ try { WHERE r.id = :rid AND r.passenger_id = :pid AND r.status IN ('accepted', 'arrived', 'started', 'begin') LIMIT 1 "); - $stmt->execute([':rid' => $rideId, ':pid' => $jwt->user_id]); + $stmt->execute([':rid' => $rideId, ':pid' => $user_id]); $ride = $stmt->fetch(); if (!$ride) { @@ -54,7 +54,7 @@ try { $payload = json_encode([ 'ride_id' => (string)$rideId, 'driver_id' => (string)$driverId, - 'passenger_id' => (string)$jwt->user_id + 'passenger_id' => (string)$user_id ]); curl_setopt_array($ch, [ @@ -99,7 +99,7 @@ try { $driverTokenRow = $stmtToken->fetch(); if ($driverTokenRow && !empty($driverTokenRow['token'])) { - sendFCMData( + sendFcmNotification( $driverTokenRow['token'], 'Incoming Call', 'Incoming WebRTC voice call', @@ -110,7 +110,8 @@ try { 'caller_avatar' => '', 'ride_id' => (string)$rideId ], - 'Call' + 'Call', + 'ding' ); }