refactor: remove the WhatsApp integration
All checks were successful
Build and deploy / Validate source (push) Successful in 15s
Build and deploy / Integration suite on a real stack (push) Successful in 4m24s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m11s
All checks were successful
Build and deploy / Validate source (push) Successful in 15s
Build and deploy / Integration suite on a real stack (push) Successful in 4m24s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m11s
The system will not send WhatsApp messages: the client's n8n already does, from Tiny's status changes. Paid orders and stage changes now queue only the Tiny delivery; the fake WhatsApp adapter, its setting and secret, the Integrações row and the send log's Destino column are gone, and the old WhatsApp log rows are removed. The customer's WhatsApp number, the "Avisar no WhatsApp" link for corrections and the contact links stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,13 +12,10 @@ from botocore.exceptions import ClientError
|
||||
def require_runtime():
|
||||
"""Validate the supported local and R2-backed deployment modes.
|
||||
|
||||
Real payment, freight, ERP, and WhatsApp providers are deliberately not
|
||||
enabled yet. A non-local deployment keeps those adapters fake and disables
|
||||
checkout until their audited implementations are added.
|
||||
Each provider is fake until its settings are complete; a real one refuses
|
||||
to start without them.
|
||||
"""
|
||||
environment = os.environ.get('APP_ENV', 'local')
|
||||
if os.environ.get('WHATSAPP_ADAPTER') != 'fake':
|
||||
raise RuntimeError('WHATSAPP must use the currently supported fake adapter')
|
||||
freight = os.environ.get('FREIGHT_ADAPTER')
|
||||
if freight == 'jadlog':
|
||||
from .jadlog import required_settings as jadlog_settings
|
||||
@@ -197,11 +194,6 @@ class FakeTiny:
|
||||
return {'provider': 'fake-tiny', 'reference': f"LOCAL-{payload['number']}",
|
||||
'event_key': event_key, 'status': 'recorded-locally'}
|
||||
|
||||
class FakeWhatsApp:
|
||||
def deliver(self, event_key: str, payload: dict) -> dict:
|
||||
return {'provider': 'fake-whatsapp', 'event_key': event_key,
|
||||
'event': payload['event'], 'status': 'recorded-locally'}
|
||||
|
||||
class ObjectStorage(Protocol):
|
||||
def begin(self, key: str) -> str: ...
|
||||
def parts(self, key: str, upload_id: str) -> list: ...
|
||||
|
||||
@@ -267,7 +267,7 @@ def payment_events(state: Literal['open','resolved','all'] = 'open',
|
||||
|
||||
|
||||
@router.get('/api/operator/events')
|
||||
def events(provider: Literal['tiny','whatsapp'] | None = None,
|
||||
def events(provider: Literal['tiny'] | None = None,
|
||||
status: Literal['delivered','queued','failing'] | None = None,
|
||||
event: Literal['payment_approved','production_started','correction_needed','ready'] | None = None,
|
||||
order: int | None = Query(default=None, ge=1), offset: int = Query(default=0, ge=0),
|
||||
@@ -631,9 +631,8 @@ def move(uid: UUID, body: Move, user=Depends(can('produce'))):
|
||||
sale = c.execute("SELECT receipt FROM dtf_local.outbox WHERE event_key=%s AND delivered_at IS NOT NULL",
|
||||
(f'{uid}:paid:tiny',)).fetchone()
|
||||
tiny = {**event, 'order': row['snapshot'], 'tiny_id': ((sale or {}).get('receipt') or {}).get('tiny_id')}
|
||||
for provider, payload in (('tiny', tiny), ('whatsapp', event)):
|
||||
key = f'{uid}:{events[body.state]}:{provider}' if once else f'{uid}:{changed["version"]}:{provider}'
|
||||
enqueue(c, key, provider, payload)
|
||||
key = f'{uid}:{events[body.state]}:tiny' if once else f'{uid}:{changed["version"]}:tiny'
|
||||
enqueue(c, key, 'tiny', tiny)
|
||||
return changed
|
||||
|
||||
@router.post('/api/operator/orders/{uid}/print-files')
|
||||
|
||||
@@ -27,7 +27,6 @@ SECRET_FILE_SETTINGS = (
|
||||
'PAYMENT_TOKEN',
|
||||
'PAYMENT_WEBHOOK_SECRET',
|
||||
'TINY_TOKEN',
|
||||
'WHATSAPP_TOKEN',
|
||||
'SMTP_PASSWORD',
|
||||
'CORREIOS_CODIGO_ACESSO',
|
||||
)
|
||||
|
||||
@@ -99,10 +99,9 @@ def create_order(c, quote, payment):
|
||||
queue_print_files(c, order['id'], len(approved['items']))
|
||||
if is_test(order):
|
||||
return order, True
|
||||
for provider in ('tiny', 'whatsapp'):
|
||||
enqueue(c, f"{order['id']}:paid:{provider}", provider,
|
||||
{'order_id': str(order['id']), 'number': order['number'],
|
||||
'event': 'payment_approved', 'order': approved})
|
||||
enqueue(c, f"{order['id']}:paid:tiny", 'tiny',
|
||||
{'order_id': str(order['id']), 'number': order['number'],
|
||||
'event': 'payment_approved', 'order': approved})
|
||||
mail.alert(c, f"Pedido #{order['number']} pago · {mail.money(approved['total_cents'])}",
|
||||
['Um pedido novo foi pago e está em Arte recebida.', '', *mail.summary(approved)], '/')
|
||||
return order, True
|
||||
|
||||
@@ -173,6 +173,9 @@ CREATE INDEX IF NOT EXISTS order_files_upload ON dtf_local.order_files(upload_id
|
||||
-- index stays the size of the backlog rather than of all history.
|
||||
CREATE INDEX IF NOT EXISTS outbox_pending ON dtf_local.outbox(available_at, id)
|
||||
WHERE delivered_at IS NULL;
|
||||
-- The system sends no WhatsApp messages (the client's own n8n does, from Tiny):
|
||||
-- its old log rows would wait for an adapter that no longer exists.
|
||||
DELETE FROM dtf_local.outbox WHERE provider='whatsapp';
|
||||
|
||||
-- The scanner and the retention sweep both walk live uploads in arrival order.
|
||||
-- now() cannot appear in a partial index predicate, so the time comparisons stay
|
||||
|
||||
@@ -7,7 +7,7 @@ import time
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from psycopg.types.json import Jsonb
|
||||
from . import mail
|
||||
from .adapters import FakeTiny, FakeWhatsApp, LocalS3Storage, require_runtime
|
||||
from .adapters import FakeTiny, LocalS3Storage, require_runtime
|
||||
from .core.secrets import load as load_secret_files
|
||||
from .core.db import connect
|
||||
from .printjobs import render_loop
|
||||
@@ -15,7 +15,7 @@ from .scanning import ClamAV, scan_loop
|
||||
|
||||
load_secret_files()
|
||||
require_runtime()
|
||||
adapters = {'tiny': FakeTiny(), 'whatsapp': FakeWhatsApp()}
|
||||
adapters = {'tiny': FakeTiny()}
|
||||
# Not yet confirmed against the client's account; see app/tiny.py.
|
||||
if os.environ.get('TINY_ADAPTER') == 'tiny':
|
||||
from .tiny import TinyOrders
|
||||
|
||||
Reference in New Issue
Block a user