Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(dashboard): show WhatsApp account restrictions on the session card
Yudhi Armyndharis5c606385adc9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fa47ee931..620988251 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added+- **The dashboard shows account restrictions on the session card**, in all 12 locales. The row is+ deliberately not gated on status, unlike the error row beside it: a reachout timelock applies to a+ session that is perfectly `ready`, and hiding it behind a failure status would make it invisible in+ exactly the case an operator needs it. The visible label is the translated kind; the engine's raw+ cause token and the expiry ride in the tooltip, since the token is searchable but not readable.+- **Enforcement and account standing are now in the audit log**, not only in the process log. Four new`AuditAction` members: `session_restricted` / `session_restriction_lifted` when WhatsApp restrictsan account or releases it, and `send_pacing_blocked` / `send_breaker_tripped` when pacing refuses adiff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.jsonindex 696bdbb9e..c83146cc8 100644--- a/dashboard/src/i18n/locales/ar.json+++ b/dashboard/src/i18n/locales/ar.json@@ -326,7 +326,8 @@"phone": "الهاتف","sessionId": "معرّف الجلسة","lastActive": "آخر نشاط",- "error": "خطأ"+ "error": "خطأ",+ "restriction": "تقييد"},"forceKill": {"title": "إنهاء جلسة عالقة",@@ -371,6 +372,12 @@"start": {"teardownPendingTitle": "بدء الجلسة","teardownPending": "لا يزال تفكيك بيانات الاعتماد لهذه الجلسة قيد التسوية. انتظر لحظة وحاول مرة أخرى."+ },+ "restriction": {+ "reachout_timelock": "المحادثات الجديدة محظورة",+ "tos_block": "محظور من واتساب",+ "proxy_block": "الاتصال محظور",+ "until": "حتى {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/de.json b/dashboard/src/i18n/locales/de.jsonindex 0ec340835..6ce11373d 100644--- a/dashboard/src/i18n/locales/de.json+++ b/dashboard/src/i18n/locales/de.json@@ -315,7 +315,8 @@"phone": "Telefon","sessionId": "Sitzungs-ID","lastActive": "Zuletzt aktiv",- "error": "Fehler"+ "error": "Fehler",+ "restriction": "Einschränkung"},"forceKill": {"title": "Hängende Sitzung zwangsweise beenden",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "Sitzung wird gestartet","teardownPending": "Ein Anmeldedatenabbau für diese Sitzung läuft noch. Warten Sie einen Moment und versuchen Sie es erneut."+ },+ "restriction": {+ "reachout_timelock": "Neue Chats blockiert",+ "tos_block": "Von WhatsApp gesperrt",+ "proxy_block": "Verbindung gesperrt",+ "until": "bis {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.jsonindex b96b2c808..b79c9e222 100644--- a/dashboard/src/i18n/locales/en.json+++ b/dashboard/src/i18n/locales/en.json@@ -319,7 +319,8 @@"phone": "Phone","sessionId": "Session ID","lastActive": "Last Active",- "error": "Error"+ "error": "Error",+ "restriction": "Restriction"},"forceKill": {"title": "Kill Stuck Session",@@ -360,6 +361,12 @@"step3": "<strong>3.</strong> Tap <strong>Link a Device</strong>, then tap <strong>Link with phone number instead</strong>","step4": "<strong>4.</strong> Enter the 8-character code shown above on your phone","waitingConnection": "Waiting for your phone to link…"+ },+ "restriction": {+ "reachout_timelock": "New chats blocked",+ "tos_block": "Blocked by WhatsApp",+ "proxy_block": "Connection blocked",+ "until": "until {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.jsonindex 188f82964..f6bacfca7 100644--- a/dashboard/src/i18n/locales/es.json+++ b/dashboard/src/i18n/locales/es.json@@ -315,7 +315,8 @@"phone": "Teléfono","sessionId": "ID de sesión","lastActive": "Última actividad",- "error": "Error"+ "error": "Error",+ "restriction": "Restricción"},"forceKill": {"title": "Cerrar sesión bloqueada",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "Iniciando sesión","teardownPending": "El borrado de credenciales de esta sesión aún está en curso. Espere un momento e inténtelo de nuevo."+ },+ "restriction": {+ "reachout_timelock": "Chats nuevos bloqueados",+ "tos_block": "Bloqueado por WhatsApp",+ "proxy_block": "Conexión bloqueada",+ "until": "hasta {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.jsonindex 1e7037268..e0208be24 100644--- a/dashboard/src/i18n/locales/fr.json+++ b/dashboard/src/i18n/locales/fr.json@@ -315,7 +315,8 @@"phone": "Téléphone","sessionId": "ID de session","lastActive": "Dernière activité",- "error": "Erreur"+ "error": "Erreur",+ "restriction": "Restriction"},"forceKill": {"title": "Arrêter la session bloquée",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "Démarrage de la session","teardownPending": "Un nettoyage d'identifiants pour cette session est encore en cours. Patientez un instant et réessayez."+ },+ "restriction": {+ "reachout_timelock": "Nouvelles discussions bloquées",+ "tos_block": "Bloqué par WhatsApp",+ "proxy_block": "Connexion bloquée",+ "until": "jusqu'au {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.jsonindex 05c1e5209..33e492103 100644--- a/dashboard/src/i18n/locales/he.json+++ b/dashboard/src/i18n/locales/he.json@@ -322,7 +322,8 @@"phone": "טלפון","sessionId": "מזהה Session","lastActive": "פעילות אחרונה",- "error": "שגיאה"+ "error": "שגיאה",+ "restriction": "הגבלה"},"forceKill": {"title": "סגירת סשן תקוע",@@ -367,6 +368,12 @@"start": {"teardownPendingTitle": "הפעלת סשן","teardownPending": "פירוק אישורים לסשן זה עדיין מתבצע. המתן רגע ונסה שוב."+ },+ "restriction": {+ "reachout_timelock": "צ׳אטים חדשים חסומים",+ "tos_block": "נחסם על ידי WhatsApp",+ "proxy_block": "החיבור חסום",+ "until": "עד {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.jsonindex 0939b8450..5ef76583e 100644--- a/dashboard/src/i18n/locales/it.json+++ b/dashboard/src/i18n/locales/it.json@@ -315,7 +315,8 @@"phone": "Telefono","sessionId": "ID Sessione","lastActive": "Ultima Attività",- "error": "Errore"+ "error": "Errore",+ "restriction": "Limitazione"},"forceKill": {"title": "Termina sessione bloccata",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "Avvio sessione","teardownPending": "Uno smontaggio delle credenziali per questa sessione è ancora in corso. Attendi un momento e riprova."+ },+ "restriction": {+ "reachout_timelock": "Nuove chat bloccate",+ "tos_block": "Bloccato da WhatsApp",+ "proxy_block": "Connessione bloccata",+ "until": "fino al {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.jsonindex ec25bdc0e..05001cc70 100644--- a/dashboard/src/i18n/locales/ko.json+++ b/dashboard/src/i18n/locales/ko.json@@ -315,7 +315,8 @@"phone": "전화번호","sessionId": "세션 ID","lastActive": "마지막 활동",- "error": "오류"+ "error": "오류",+ "restriction": "제한"},"forceKill": {"title": "멈춘 세션 강제 종료",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "세션 시작 중","teardownPending": "이 세션의 자격 증명 해체가 아직 진행 중입니다. 잠시 기다린 후 다시 시도하세요."+ },+ "restriction": {+ "reachout_timelock": "새 대화 차단됨",+ "tos_block": "WhatsApp에 의해 차단됨",+ "proxy_block": "연결 차단됨",+ "until": "{{date}}까지"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.jsonindex e9e900f66..a7edae498 100644--- a/dashboard/src/i18n/locales/pt-BR.json+++ b/dashboard/src/i18n/locales/pt-BR.json@@ -315,7 +315,8 @@"phone": "Telefone","sessionId": "ID da sessão","lastActive": "Última atividade",- "error": "Erro"+ "error": "Erro",+ "restriction": "Restrição"},"forceKill": {"title": "Forçar encerramento da sessão travada",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "Iniciando sessão","teardownPending": "A remoção de credenciais desta sessão ainda está em andamento. Aguarde um momento e tente novamente."+ },+ "restriction": {+ "reachout_timelock": "Novas conversas bloqueadas",+ "tos_block": "Bloqueado pelo WhatsApp",+ "proxy_block": "Conexão bloqueada",+ "until": "até {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.jsonindex 3be14660e..585d3a91f 100644--- a/dashboard/src/i18n/locales/te.json+++ b/dashboard/src/i18n/locales/te.json@@ -315,7 +315,8 @@"phone": "ఫోన్","sessionId": "సెషన్ ID","lastActive": "చివరిసారి యాక్టివ్",- "error": "లోపం"+ "error": "లోపం",+ "restriction": "ఆంక్ష"},"forceKill": {"title": "నిలిచిపోయిన సెషన్ను ఆపండి",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "సెషన్ ప్రారంభం","teardownPending": "ఈ సెషన్ యొక్క ఆధారాల విచ్ఛిన్నం ఇంకా స్థిరపడుతోంది. కొద్దిసేపు ఆగి మళ్లీ ప్రయత్నించండి."+ },+ "restriction": {+ "reachout_timelock": "కొత్త చాట్లు నిరోధించబడ్డాయి",+ "tos_block": "WhatsApp ద్వారా నిరోధించబడింది",+ "proxy_block": "కనెక్షన్ నిరోధించబడింది",+ "until": "{{date}} వరకు"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.jsonindex 4ecd7a583..04892153a 100644--- a/dashboard/src/i18n/locales/zh-CN.json+++ b/dashboard/src/i18n/locales/zh-CN.json@@ -315,7 +315,8 @@"phone": "电话","sessionId": "会话 ID","lastActive": "上次活跃",- "error": "错误"+ "error": "错误",+ "restriction": "限制"},"forceKill": {"title": "终止卡死的会话",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "会话启动中","teardownPending": "此会话的凭据拆除仍在处理中。请稍候再试。"+ },+ "restriction": {+ "reachout_timelock": "新会话被阻止",+ "tos_block": "被 WhatsApp 封禁",+ "proxy_block": "连接被阻止",+ "until": "至 {{date}}"}},"webhooks": {diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.jsonindex 16525c083..d2db8878d 100644--- a/dashboard/src/i18n/locales/zh-HK.json+++ b/dashboard/src/i18n/locales/zh-HK.json@@ -315,7 +315,8 @@"phone": "電話","sessionId": "工作階段 ID","lastActive": "上次活躍",- "error": "錯誤"+ "error": "錯誤",+ "restriction": "限制"},"forceKill": {"title": "強制終止卡住的工作階段",@@ -360,6 +361,12 @@"start": {"teardownPendingTitle": "工作階段啟動中","teardownPending": "此工作階段的憑證拆除仍在進行中。請稍候再試。"+ },+ "restriction": {+ "reachout_timelock": "新對話被封鎖",+ "tos_block": "被 WhatsApp 封鎖",+ "proxy_block": "連線被封鎖",+ "until": "至 {{date}}"}},"webhooks": {diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.cssindex 4f86f95f6..2bc3b667d 100644--- a/dashboard/src/pages/Sessions.css+++ b/dashboard/src/pages/Sessions.css@@ -160,6 +160,19 @@white-space: nowrap;}+/* Mirrors .error-text, in warning rather than error: a restriction is WhatsApp limiting the account,+ not the gateway failing. --warning is :root-only and inherited by both themes, the same way+ --error is, so it needs no dark-mode override. */+.sessions-page .info-value.restriction-text {+ color: var(--warning);+ font-weight: 500;+ max-width: 60%;+ text-align: right;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.sessions-page .card-actions {display: flex;gap: 0.5rem;diff --git a/dashboard/src/pages/Sessions.test.ts b/dashboard/src/pages/Sessions.test.tsindex d595ac198..1652332d8 100644--- a/dashboard/src/pages/Sessions.test.ts+++ b/dashboard/src/pages/Sessions.test.ts@@ -45,7 +45,21 @@ const SESSION_STALE_ENGINE: Session = {updatedAt: '2026-01-01T00:00:00.000Z',};-const SESSIONS = [SESSION_QR, SESSION_STALE_ENGINE];+// A reachout timelock leaves the account fully connected — `ready` plus a restriction is the normal+// shape, and the card must show it there. A restriction hidden behind a failed/disconnected status+// (the rule `lastError` follows) would be invisible in exactly the case that matters.+const SESSION_TIMELOCKED: Session = {+ id: 'sess-limited-1',+ name: 'limited-bot',+ status: 'ready',+ engineLoaded: true,+ phone: '15550001111',+ createdAt: '2026-01-01T00:00:00.000Z',+ updatedAt: '2026-01-01T00:00:00.000Z',+ restriction: { kind: 'reachout_timelock', code: 'BIZ_QUALITY', expiresAt: '2026-08-04T09:00:00.000Z' },+};++const SESSIONS = [SESSION_QR, SESSION_STALE_ENGINE, SESSION_TIMELOCKED];function jsonResponse(data: unknown, status = 200): Response {return new Response(JSON.stringify(data), {@@ -292,3 +306,28 @@ test('stopping a session dismisses its own open QR modal', async () => {assert.ok(!screen.queryByRole('dialog'), 'the QR modal stayed open after its session stopped');});});++test('a restricted session shows the restriction on its card, even while it is ready', async () => {+ const { screen, within } = rtl;+ resetFetchCalls();+ renderSessions();++ const card = (await screen.findByText('limited-bot')).closest('.session-card') as HTMLElement;++ within(card).getByText('Restriction');+ const value = within(card).getByText('New chats blocked');+ // The raw engine token and the expiry ride in the tooltip: `code` is searchable but not readable,+ // so it must not become the visible label.+ assert.match(value.getAttribute('title') ?? '', /BIZ_QUALITY/);+ assert.match(value.getAttribute('title') ?? '', /until/);+});++test('an unrestricted session shows no restriction row', async () => {+ const { screen, within } = rtl;+ resetFetchCalls();+ renderSessions();++ const card = (await screen.findByText('stale-engine')).closest('.session-card') as HTMLElement;++ assert.equal(within(card).queryByText('Restriction'), null);+});diff --git a/dashboard/src/pages/Sessions.tsx b/dashboard/src/pages/Sessions.tsxindex da9110219..26cbdf071 100644--- a/dashboard/src/pages/Sessions.tsx+++ b/dashboard/src/pages/Sessions.tsx@@ -15,7 +15,7 @@ import {Skull,Unlink,} from 'lucide-react';-import { sessionApi, type Session } from '../services/api';+import { sessionApi, type Session, type AccountRestriction } from '../services/api';import { queryKeys } from '../hooks/queries';import { useDocumentTitle } from '../hooks/useDocumentTitle';import {@@ -30,6 +30,7 @@ import { canCreateSession, filterSessions, isValidPairingPhone, sessionNameIssueimport { useToast } from '../hooks/useToast';import { useRole } from '../hooks/useRole';import { useSessionPairing } from '../hooks/useSessionPairing';+import type { TFunction } from 'i18next';import { useSessionFeed } from '../hooks/useSessionFeed';import { useSessionCreateForm } from '../hooks/useSessionCreateForm';import { PageHeader } from '../components/PageHeader';@@ -37,6 +38,19 @@ import { CustomSelect } from '../components/CustomSelect';import { Modal } from '../components/Modal';import './Sessions.css';+/**+ * The hover title for a restriction: the engine's own cause token, plus when enforcement ends if+ * WhatsApp said. The visible label stays the translated kind — `code` is a raw upstream token+ * (`TOS_BLOCK`, `BIZ_QUALITY`) that is searchable but not readable, so it belongs in the tooltip.+ */+function restrictionTitle(restriction: AccountRestriction, t: TFunction): string {+ const parts = [t(`sessions.restriction.${restriction.kind}`), restriction.code];+ if (restriction.expiresAt) {+ parts.push(t('sessions.restriction.until', { date: new Date(restriction.expiresAt).toLocaleString() }));+ }+ return parts.join(' · ');+}+export function Sessions() {const { t } = useTranslation();useDocumentTitle(t('sessions.title'));@@ -746,6 +760,17 @@ export function Sessions() {</span></div>) : null}+ {/* Not gated on status, unlike the error above: a reachout timelock applies to a+ session that is perfectly `ready`, and hiding it behind a status would make it+ invisible exactly when the operator needs it. */}+ {session.restriction ? (+ <div className="info-row session-restriction">+ <span className="info-label">{t('sessions.card.restriction')}</span>+ <span className="info-value restriction-text" title={restrictionTitle(session.restriction, t)}>+ {t(`sessions.restriction.${session.restriction.kind}`)}+ </span>+ </div>+ ) : null}</div>)}diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex 37ebf95a1..b6163b912 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -49,6 +49,27 @@ export interface Session {/** Human-readable reason carried while the status is 'failed' (terminal failure) or* 'action_required' (operator must intervene, e.g. acknowledge an onboarding modal). */lastError?: string | null;+ /**+ * A limit WhatsApp itself has placed on the account, or null when there is none. Distinct from+ * `lastError`, which describes a fault on the gateway's side of the link. Optional only because a+ * dashboard can be served by a gateway that predates the field.+ */+ restriction?: AccountRestriction | null;+}++/**+ * A restriction WhatsApp has in force on a session's account.+ *+ * `reachout_timelock` leaves the session connected and existing chats working — only starting new+ * conversations is blocked — which is why it can appear on a perfectly `ready` session. `tos_block`+ * and `proxy_block` refuse the connection itself and so cannot.+ */+export interface AccountRestriction {+ kind: 'reachout_timelock' | 'tos_block' | 'proxy_block';+ /** The engine's own token for the cause, verbatim (`TOS_BLOCK`, `BIZ_QUALITY`, …). */+ code: string;+ /** ISO timestamp when enforcement ends, when WhatsApp states one. */+ expiresAt?: string | null;}export interface SessionStats {