Send each order status to the status workflow only once
All checks were successful
Build and Deploy / build-and-push (push) Successful in 38s
All checks were successful
Build and Deploy / build-and-push (push) Successful in 38s
Tiny fires an order webhook on every edit, not only on status changes, and the middleware forwarded all of them, so n8n could send the customer the same WhatsApp again (seen: order 986470642 got "enviado" twice within 2 minutes). Remember the last status forwarded per order and skip repeats: - recorded only after n8n accepted it and only for orders with Tiny data, so failed or incomplete sends can still go through; - claimed before sending, so simultaneous duplicates send once; - saved to data-runtime/status_notifications_sent.json (30-day TTL) so redeploys don't resend; re-read when another container updates it; - a real change back to an earlier status is still sent; - the Graphs workflow still receives every update. STATUS_DEDUPE_ENABLED=false turns it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
// Each test file runs in its own process; set env before requiring app modules,
|
||||
// since they read their config at load time.
|
||||
@@ -9,6 +12,7 @@ export function setTestEnv(overrides: Record<string, string>) {
|
||||
delete process.env.NEXSTAR_GRAPHS_API_URL;
|
||||
delete process.env.TINY_LIVE_MAX_QUEUE_WAIT_MS;
|
||||
Object.assign(process.env, {
|
||||
RUNTIME_DATA_DIR: fs.mkdtempSync(path.join(os.tmpdir(), 'tiny-webhook-test-')),
|
||||
TINY_API_TOKEN: 'mock-token',
|
||||
N8N_WEBHOOK_STATUS: 'http://n8n.test/status',
|
||||
TINY_LIVE_REQUEST_DELAY_MS: '0',
|
||||
|
||||
Reference in New Issue
Block a user