<?php
require_once __DIR__.'/../includes/functions.php';
header('Content-Type: application/json');
$u=current_user(); if(!$u){ http_response_code(401); echo json_encode(['error'=>'login_required']); exit; }
$rows = table_exists('mj_notifications') ? all_rows('SELECT * FROM mj_notifications WHERE user_id=? ORDER BY created_at DESC LIMIT 30',[(int)$u['id']]) : [];
echo json_encode(['ok'=>true,'notifications'=>$rows]);
