;ll123Scurity:6 \Fix HMAC handshake, generate API keys in Google Login, and relax JWT issuer
This commit is contained in:
@@ -59,20 +59,34 @@ class NotificationController extends Controller
|
|||||||
/** POST /v2/notifications/update (For V1 Compatibility) */
|
/** POST /v2/notifications/update (For V1 Compatibility) */
|
||||||
public function updateNotification(Request $request): JsonResponse
|
public function updateNotification(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$id = $request->input('id');
|
try {
|
||||||
if (!$id) {
|
$id = $request->input('id');
|
||||||
return response()->json(['status' => 'failure', 'message' => 'Missing notification ID']);
|
if (!$id) {
|
||||||
|
return response()->json(['status' => 'failure', 'message' => 'Missing notification ID']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$isShown = $request->input('isShown', 'true');
|
||||||
|
$userId = $request->attributes->get('_jwt_user_id');
|
||||||
|
$userType = $request->attributes->get('_jwt_user_type');
|
||||||
|
|
||||||
|
$table = $userType === 'driver' ? 'notificationCaptain' : 'notifications';
|
||||||
|
$userField = $userType === 'driver' ? 'driverID' : 'passenger_id';
|
||||||
|
|
||||||
|
$affected = DB::connection('primary')->table($table)
|
||||||
|
->where('id', $id)
|
||||||
|
->where($userField, $userId)
|
||||||
|
->update(['isShown' => $isShown]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'affected' => $affected
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'failure',
|
||||||
|
'message' => 'Internal error: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$isShown = $request->input('isShown', 'true');
|
|
||||||
$userType = $request->attributes->get('_jwt_user_type');
|
|
||||||
$table = $userType === 'driver' ? 'notificationCaptain' : 'notifications';
|
|
||||||
|
|
||||||
DB::connection('primary')->table($table)
|
|
||||||
->where('id', $id)
|
|
||||||
->update(['isShown' => $isShown]);
|
|
||||||
|
|
||||||
return response()->json(['status' => 'success']);
|
|
||||||
}
|
}
|
||||||
/** POST /v2/notifications/token */
|
/** POST /v2/notifications/token */
|
||||||
public function updateToken(Request $request): JsonResponse
|
public function updateToken(Request $request): JsonResponse
|
||||||
|
|||||||
Reference in New Issue
Block a user