res_parking was configured in M0 (700, slots 701-720, slot hints); this makes parked calls visible. ParkingTracker loads ParkedCalls and follows ParkedCall/UnParkedCall/ParkedCallTimeOut/ParkedCallGiveUp; everyone gets parked.updated/parked.removed. Who parked comes from ParkerDialString. A blind transfer to 700 parks without running Park() in the dialplan, so the live call's "parked" state now comes from those events by ParkeeLinkedid; the picking-up phone runs ParkedCall() while talking, which no longer counts as parked. Web: "Parked calls" on the Dashboard and on Home, where "Pick up 701" calls the slot like Call back (softphone, or the desk phone first). CDR fixture park-pickup (recorded: 101 parks an inbound call, 103 picks it up); the call counts as answered by 101 with 103 in rang. e2e m8-t2 with real phones: park by blind transfer, hint InUse, both lists, pick up from Home, a second park on 702 (findslot = next) picked up by dialing it from another phone. Specs 01/04/05 note what was verified. Task: M8-T2
33 lines
1.1 KiB
JavaScript
33 lines
1.1 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 action on its own session; rejects on Response: Error. */
|
|
export function action(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: a1[\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, ActionID: 'a1' })
|
|
.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`,
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
/** One AMI Originate with a caller ID (the CLI can't set one). */
|
|
export const originate = (fields) => action({ ...fields, Action: 'Originate', Async: 'true' });
|