feat(connect): caller ID as an integration: calls on the signed-in live connection, matched on the server
Plan step 3.5.
- The public /api/phone/ws socket is removed (anyone on the LAN could listen to every
caller). GET /api/phone/call-event stays public for the Grandstream UCM but is LAN-only in
the proxy (the 443 blocks' LAN-only location now covers it, in nginx-proxy/nginx.conf and
install.sh), with an optional shared secret (setting caller_id.secret → &key=).
- Calls are logged (phone_calls, migration 0023), matched to a customer on the server
(services/caller_id.py: Greek number rules moved from the manager) and published as
`call_incoming` {call_id, at, number, ext, customer card: visits, spent, last 3 orders} to
users with caller_id.use and to the counter POS screens. GET /api/phone/calls (the log),
GET /api/customers/lookup?phone=. Calls older than a minute don't pop up (replays).
- Manager: PhoneListener on the live connection and the shared Dialog (no more downloading
every customer to match); Integrations → Caller ID shows the server's log live and the UCM
Action URL. Counter: CallPopup with "New takeaway sale".
- Tests: tests/test_caller_id.py (10), terminal unit test, e2e terminal and manager.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -732,6 +732,24 @@ try {
|
||||
r.check('3.4: …or a slideshow of its photos, with its line of text',
|
||||
await myDisplay.waitForFunction(() => document.querySelectorAll('[data-testid="display-slide"]').length === 2, null, { timeout: 20_000 }).then(() => true).catch(() => false)
|
||||
&& (await myDisplay.getByTestId('display-message').textContent()) === 'Today: 2 for 1')
|
||||
// ── 3.5: caller ID at the counter ────────────────────────────────────────
|
||||
await api('PUT', '/api/platform/modules/caller_id', { token: boss, body: { enabled: true } }).catch(() => {})
|
||||
await api('POST', '/api/customers/', { token: boss, body: { name: 'Kostas Regular', phone: '+30 697 555 1234', notes: 'Always extra tzatziki' } })
|
||||
const callRes = await fetch(`${backend.url}/api/phone/call-event?caller=6975551234&ext=100`)
|
||||
r.check('3.5: the phone system\'s webhook takes the call', callRes.ok, String(callRes.status))
|
||||
r.check('3.5: the counter pops up who is calling (matched on the server)', await shown(page, 'call-popup', 8000)
|
||||
&& (await page.getByTestId('call-name').textContent()) === 'Kostas Regular' && (await page.getByTestId('call-popup').textContent()).includes('extra tzatziki'))
|
||||
await page.screenshot({ path: path.join(OUT, 'terminal-pos-call.png') })
|
||||
await page.getByTestId('call-takeaway').click()
|
||||
r.check('3.5: …"New takeaway sale" opens a takeaway sale', await page.getByTestId('type-takeaway').getAttribute('aria-checked') === 'true'
|
||||
&& await page.getByTestId('call-popup').count() === 0)
|
||||
const oldWs = await new Promise(res => {
|
||||
const ws = new WebSocket(`${backend.url.replace('http', 'ws')}/api/phone/ws`)
|
||||
ws.onopen = () => { ws.close(); res('open') }
|
||||
ws.onerror = () => res('refused')
|
||||
setTimeout(() => res('timeout'), 5000)
|
||||
})
|
||||
r.check('3.5: the old public call socket is gone (nothing listens without signing in)', oldWs !== 'open', oldWs)
|
||||
await myDisplay.context().close()
|
||||
await otherDisplay.context().close()
|
||||
drawerServer.close()
|
||||
|
||||
Reference in New Issue
Block a user