Fix Associazione ricevute

This commit is contained in:
2026-03-19 16:55:31 +01:00
parent 3bdb32e6ae
commit c34d6bb080
15 changed files with 59 additions and 44 deletions
+12 -12
View File
@@ -1,4 +1,4 @@
# PecFlow Architettura di Sistema
# PEChub Architettura di Sistema
> **Documento redatto il:** 2026-03-18 | **Ultima revisione:** 2026-03-18
> **Versione:** 2.0
@@ -26,7 +26,7 @@ Monorepo con workspace separati. Il confine di responsabilità è netto: ogni
cartella di primo livello è un deployable (o una libreria condivisa) indipendente.
```
PecFlow/ ← root del monorepo
PEChub/ ← root del monorepo
├── .github/ ← CI/CD GitHub Actions
│ ├── workflows/
@@ -279,14 +279,14 @@ PecFlow/ ← root del monorepo
│ ├── nginx/
│ │ ├── nginx.conf # reverse proxy, rate limiting, TLS termination
│ │ └── conf.d/
│ │ └── pecflow.conf
│ │ └── pechub.conf
│ ├── redis/
│ │ └── redis.conf # maxmemory, eviction policy
│ ├── prometheus/
│ │ └── prometheus.yml
│ └── grafana/
│ └── dashboards/
│ └── pecflow.json
│ └── pechub.json
└── docs/ ═══════════════════════════════
├── api/ ← OpenAPI spec generata (non commitare auto-gen)
@@ -326,7 +326,7 @@ CREATE EXTENSION IF NOT EXISTS "pgcrypto"; -- gen_random_bytes per nonce AES
-- ============================================================
CREATE TABLE tenants (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
slug VARCHAR(63) NOT NULL UNIQUE, -- usato come subdomain: acme.pecflow.it
slug VARCHAR(63) NOT NULL UNIQUE, -- usato come subdomain: acme.pechub.it
name VARCHAR(255) NOT NULL,
plan VARCHAR(50) NOT NULL DEFAULT 'starter', -- starter|pro|enterprise
is_active BOOLEAN NOT NULL DEFAULT TRUE,
@@ -1000,7 +1000,7 @@ Il conservatore AgID può essere temporaneamente non disponibile (manutenzione,
**Strategia:**
1. **Backoff esponenziale con jitter:** tentativo 1 subito, poi 1h, 4h, 24h (max 3 retry oltre il primo)
2. **Dead letter queue:** dopo tutti i retry falliti, il batch va in stato `failed` e genera un alert email all'admin del tenant + al team ops PecFlow
2. **Dead letter queue:** dopo tutti i retry falliti, il batch va in stato `failed` e genera un alert email all'admin del tenant + al team ops PEChub
3. **Idempotenza:** prima di ogni retry, verificare se il conservatore ha già ricevuto il versamento (`GET /versamento/{id}`) per evitare duplicati
4. **Finestra di versamento:** i versamenti periodici (es. mensili) devono completarsi entro la scadenza normativa; se il sistema prevede che non ce la farà, genera alert anticipato a 72h dalla scadenza
5. **Circuit breaker:** se il conservatore fallisce 5 volte in 1 ora, si sospendono tutti i versamenti verso quel conservatore per 30 minuti (evita tempesta di retry)
@@ -1418,7 +1418,7 @@ alla Fase 1, le altre possono essere sviluppate in parallelo al frontend (Fase 5
- [ ] API `POST /notifications/rules` (crea regola evento → canale + filtri)
- [ ] `notification_service.py`: al salvataggio di ogni messaggio, valuta regole applicabili e accoda job
- [ ] `worker/notifications/dispatcher.py`: smista per tipo canale
- [ ] `webhook.py`: POST JSON con header `X-PecFlow-Signature: sha256=<HMAC>` per verifica autenticità
- [ ] `webhook.py`: POST JSON con header `X-PEChub-Signature: sha256=<HMAC>` per verifica autenticità
- [ ] `email_smtp.py`: template HTML notifica (oggetto, mittente, link messaggio)
- [ ] `telegram.py`: messaggio Telegram con MarkdownV2, link deep al messaggio
- [ ] `whatsapp.py`: Meta Cloud API `POST /messages` con template pre-approvato (o freeform in 24h window)
@@ -1668,10 +1668,10 @@ Evento PEC (trigger: salvataggio nuovo messaggio o cambio stato)
**Webhook**
```json
POST https://your-endpoint.com/pecflow-hook
POST https://your-endpoint.com/pechub-hook
Headers:
X-PecFlow-Event: message.received
X-PecFlow-Signature: sha256=<HMAC-SHA256(secret, body)>
X-PEChub-Event: message.received
X-PEChub-Signature: sha256=<HMAC-SHA256(secret, body)>
Content-Type: application/json
Body:
@@ -1685,7 +1685,7 @@ Body:
"mailbox": "info@azienda.it",
"received_at": "2026-03-18T14:00:00Z",
"state": "received",
"url": "https://app.pecflow.it/messages/..."
"url": "https://app.pechub.it/messages/..."
}
}
```
@@ -1702,7 +1702,7 @@ Notifica in HTML via template configurabile. Il mittente usa un relay SMTP dedic
📋 Oggetto: Convocazione riunione del 20/03/2026
🕐 Ricevuta: 18/03/2026 14:00
🔗 Visualizza: https://app.pecflow.it/messages/...
🔗 Visualizza: https://app.pechub.it/messages/...
```
**WhatsApp (Meta Cloud API)**