feat: add in-app notifications system with bell icon, polling, and notifications page
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user