fix: namespace crypto storage per account, add chat polling, fix notification flow and dark theme issues
This commit is contained in:
@@ -43,8 +43,8 @@ if (!$type) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Only handle settled invoices
|
||||
if ($type !== 'InvoiceSettled' && $type !== 'InvoicePaymentSettled') {
|
||||
// Only handle fully settled invoices (not partial payment events)
|
||||
if ($type !== 'InvoiceSettled') {
|
||||
echo json_encode(['ok' => true, 'action' => 'ignored', 'type' => $type]);
|
||||
exit;
|
||||
}
|
||||
@@ -125,29 +125,49 @@ curl_close($gch);
|
||||
$listingData = json_decode($getResponse, true);
|
||||
$userCreated = $listingData['data']['user_created'] ?? null;
|
||||
|
||||
// Create notification for listing owner
|
||||
// Create notification for listing owner (skip if already exists)
|
||||
if ($userCreated) {
|
||||
$notifPayload = json_encode([
|
||||
'user_hash' => $userCreated,
|
||||
'type' => 'listing_published',
|
||||
'reference_id' => $listingId,
|
||||
'read' => false,
|
||||
$checkUrl = DIRECTUS_URL . '/items/notifications?' . http_build_query([
|
||||
'filter' => json_encode([
|
||||
'user_hash' => ['_eq' => $userCreated],
|
||||
'type' => ['_eq' => 'listing_published'],
|
||||
'reference_id' => ['_eq' => $listingId],
|
||||
]),
|
||||
'limit' => 1,
|
||||
]);
|
||||
|
||||
$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,
|
||||
],
|
||||
$ech = curl_init($checkUrl);
|
||||
curl_setopt_array($ech, [
|
||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . DIRECTUS_TOKEN],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
]);
|
||||
curl_exec($nch);
|
||||
curl_close($nch);
|
||||
$existingResp = curl_exec($ech);
|
||||
curl_close($ech);
|
||||
$existingData = json_decode($existingResp, true);
|
||||
|
||||
if (empty($existingData['data'])) {
|
||||
$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