feat: add in-app notifications system with bell icon, polling, and notifications page

This commit is contained in:
2026-02-07 14:18:00 +01:00
parent 1bd44e6632
commit f6ba0085f9
11 changed files with 585 additions and 0 deletions

View File

@@ -109,4 +109,32 @@ if ($directusStatus >= 400) {
exit;
}
// Create notification for listing owner
$listingData = json_decode($directusResponse, true);
$userCreated = $listingData['data']['user_created'] ?? null;
if ($userCreated) {
$notifPayload = json_encode([
'user_hash' => $userCreated,
'type' => 'listing_published',
'reference_id' => $listingId,
'read' => false,
]);
$notifUrl = DIRECTUS_URL . '/items/notifications';
$nch = curl_init($notifUrl);
curl_setopt_array($nch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $notifPayload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . DIRECTUS_TOKEN,
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
]);
curl_exec($nch);
curl_close($nch);
}
echo json_encode(['ok' => true, 'listingId' => $listingId, 'action' => 'published']);