add new features like realtime 2026-05-29-00

This commit is contained in:
Hamza-Ayed
2026-05-29 00:49:58 +03:00
parent d2237a54e4
commit 97907bde94
2 changed files with 20 additions and 18 deletions

View File

@@ -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'
);
}

View File

@@ -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'
);
}