dial plan: made from routes and number lengths; Yealink dial-now, the ATA plan on the Credentials tab

This commit is contained in:
iamdoubz committed 2026-10-21 17:14:13 -05:00
1 parent eacc571093
commit 0deff2a637
18 files changed
+284 -21

No files matched your search

+2
View File
@@ -53,6 +53,8 @@ export type SipCredentials = {
password: string;
/** Browser softphone identity (when webrtc is on). */
webUsername: string | null;
/** For analog adapters set up by hand (Grandstream syntax): what's complete when dialed. */
dialPlan: string;
};
/** GET /api/me/webrtc: what the browser softphone registers with (05 §5.2). */
+18 -6
View File
@@ -60,12 +60,24 @@ describe('formatNumber', () => {
});
describe('isReservedNumber', () => {
it.each(['211', '311', '411', '511', '611', '711', '811', '911', '933', '0123', '1000', '10000'])(
'%s is reserved',
(n) => {
expect(isReservedNumber(n)).toBe(true);
},
);
it.each([
'211',
'311',
'411',
'511',
'611',
'711',
'811',
'911',
'933',
'0123',
'1000',
'10000',
'9110',
'99112',
])('%s is reserved', (n) => {
expect(isReservedNumber(n)).toBe(true);
});
it.each(['100', '101', '499', '500', '700', '912', '011', '2000'])('%s is free', (n) => {
expect(isReservedNumber(n)).toBe(false);
});
+5 -2
View File
@@ -25,7 +25,10 @@ export function formatNumber(n: string): string {
return m ? `(${m[1]}) ${m[2]}-${m[3]}` : n;
}
/** N11 service codes, 933, and anything starting with 0 or 1 followed by more than 2 digits. */
/**
* N11 service codes, 933, anything starting with 0 or 1 followed by more than 2 digits, and
* anything starting with 911 or 9911 (phones send those the moment they're dialed).
*/
export function isReservedNumber(n: string): boolean {
return RESERVED.has(n) || /^[01]\d{3,}$/.test(n);
return RESERVED.has(n) || /^[01]\d{3,}$/.test(n) || /^9?911/.test(n);
}