Commit 8c593ef8 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: chat.php — add 'after' parameter for incremental message polling

The client sends `after: lastTime` to fetch only new messages since the
last poll. Server now handles this with `created_at gt.{after}` filter.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 48cb8d60
...@@ -25,6 +25,7 @@ if ($method === 'GET') { ...@@ -25,6 +25,7 @@ if ($method === 'GET') {
if (!$friendship) jsonError('Not friends'); if (!$friendship) jsonError('Not friends');
$before = $_GET['before'] ?? null; $before = $_GET['before'] ?? null;
$after = $_GET['after'] ?? null;
$limit = min(intval($_GET['limit'] ?? 50), 100); $limit = min(intval($_GET['limit'] ?? 50), 100);
$params = [ $params = [
...@@ -33,7 +34,10 @@ if ($method === 'GET') { ...@@ -33,7 +34,10 @@ if ($method === 'GET') {
'order' => 'created_at.desc', 'order' => 'created_at.desc',
'limit' => $limit 'limit' => $limit
]; ];
if ($before) { if ($after) {
$params['created_at'] = 'gt.' . $after;
$params['order'] = 'created_at.asc';
} elseif ($before) {
$params['created_at'] = 'lt.' . $before; $params['created_at'] = 'lt.' . $before;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment