Files
selfphoneng/scripts/e2e/ami.mjs
T
iamdoubz 4b6b95090a recordings: record calls, link them to history, Recordings page
sp-sub-record now also sets CDR(SP_REC); phone numbers can record every
call (record_inbound), with the notice from Settings → Recording played
first (SP_REC_ANNOUNCE). Aggregation links the MixMonitor file as a
recordings row (size, ffprobe length). /api/recordings lists, plays
(Range; admins and the people on the call) and deletes; recordings past
recordings.retentionDays are deleted daily.

Web: Recordings page (play, download, delete), a player in Call history
and My calls, a Recording settings tab with the consent notice (08 §5),
and "Record every call" on phone numbers.

e2e m7-t3: the notice plays before a recorded inbound call and the
recording plays from Call history (the M7 acceptance). The AMI
Originate helper moved to scripts/e2e/ami.mjs.

Task: M7-T3
2026-10-18 14:57:52 -05:00

35 lines
1.0 KiB
JavaScript

// SPDX-License-Identifier: AGPL-3.0-or-later
// A raw AMI session for the e2e scripts (the m2-live Asterisk publishes AMI on 127.0.0.1:15038).
import { Socket } from 'node:net';
/** One AMI Originate with a caller ID (the CLI can't set one). */
export function originate(fields) {
return new Promise((resolve, reject) => {
const s = new Socket();
let buf = '';
s.setEncoding('utf8');
s.on('data', (d) => {
buf += d;
if (/Response: Error/.test(buf)) reject(new Error(buf));
if (/ActionID: o1[\s\S]*\r\n\r\n/.test(buf)) {
s.end();
resolve();
}
});
s.on('error', reject);
s.connect(15038, '127.0.0.1', () => {
const lines = Object.entries({
...fields,
Action: 'Originate',
Async: 'true',
ActionID: 'o1',
})
.map(([k, v]) => `${k}: ${v}`)
.join('\r\n');
s.write(
`Action: Login\r\nUsername: selfphoneng\r\nSecret: m2-live-secret\r\nEvents: off\r\n\r\n${lines}\r\n\r\n`,
);
});
});
}