feat: enable person lines that are not connected to the single shared line
This commit is contained in:
parent
377da49818
commit
31b0c5789a
5 changed files with 19 additions and 4 deletions
|
|
@ -42,14 +42,18 @@ let
|
||||||
# Shared phones (no personal mailbox) and sip-clients use L1 for everything.
|
# Shared phones (no personal mailbox) and sip-clients use L1 for everything.
|
||||||
phoneHasL2 = key:
|
phoneHasL2 = key:
|
||||||
let phone = allPhones.${key};
|
let phone = allPhones.${key};
|
||||||
in phone.personKey != null && models.${phone.model}.hasMultiLine;
|
in phone.personKey != null && phone.sharedLine && models.${phone.model}.hasMultiLine;
|
||||||
|
|
||||||
# Dial target: L2 for provisioned phones, L1 for sip-clients (can only register once)
|
# Dial target: L2 for provisioned phones, L1 for sip-clients (can only register once)
|
||||||
dialTarget = key: if phoneHasL2 key then "PJSIP/${key}-l2" else "PJSIP/${key}";
|
dialTarget = key: if phoneHasL2 key then "PJSIP/${key}-l2" else "PJSIP/${key}";
|
||||||
|
|
||||||
# Dial target strings
|
# Dial target strings
|
||||||
|
# L2 endpoints for "all" DID routing: shared phones (always) + persons with sharedLine = true
|
||||||
allL2Endpoints = lib.concatStringsSep "&"
|
allL2Endpoints = lib.concatStringsSep "&"
|
||||||
(map dialTarget (lib.attrNames allPhones));
|
(map dialTarget
|
||||||
|
(lib.attrNames (lib.filterAttrs (_: phone:
|
||||||
|
phone.personKey == null || phone.sharedLine
|
||||||
|
) allPhones)));
|
||||||
|
|
||||||
personL1Endpoints = personKey:
|
personL1Endpoints = personKey:
|
||||||
lib.concatStringsSep "&"
|
lib.concatStringsSep "&"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ let
|
||||||
# Whether a phone gets an L2 line (same logic as asterisk.nix)
|
# Whether a phone gets an L2 line (same logic as asterisk.nix)
|
||||||
phoneHasL2 = key:
|
phoneHasL2 = key:
|
||||||
let phone = allPhones.${key};
|
let phone = allPhones.${key};
|
||||||
in phone.personKey != null && models.${phone.model}.hasMultiLine;
|
in phone.personKey != null && phone.sharedLine && models.${phone.model}.hasMultiLine;
|
||||||
|
|
||||||
# ── Nodes ───────────────────────────────────────────────────────────────
|
# ── Nodes ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,15 @@ in {
|
||||||
default = "";
|
default = "";
|
||||||
description = "Name shown in the directory and on caller ID.";
|
description = "Name shown in the directory and on caller ID.";
|
||||||
};
|
};
|
||||||
|
sharedLine = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether this person's phones participate in the shared/family line (L2).
|
||||||
|
Set to false for persons who should only be reachable on their personal
|
||||||
|
extension and must not appear in "all" DID routing.
|
||||||
|
'';
|
||||||
|
};
|
||||||
mailbox = lib.mkOption {
|
mailbox = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ let
|
||||||
extension = p.extension;
|
extension = p.extension;
|
||||||
displayName = p.displayName;
|
displayName = p.displayName;
|
||||||
personKey = null;
|
personKey = null;
|
||||||
|
sharedLine = true; # shared phones always participate in shared line
|
||||||
mailboxExt = null; # shared phones have no personal mailbox
|
mailboxExt = null; # shared phones have no personal mailbox
|
||||||
}) cfg.sharedPhones
|
}) cfg.sharedPhones
|
||||||
//
|
//
|
||||||
|
|
@ -71,6 +72,7 @@ let
|
||||||
extension = person.extension;
|
extension = person.extension;
|
||||||
displayName = person.displayName;
|
displayName = person.displayName;
|
||||||
personKey = personKey;
|
personKey = personKey;
|
||||||
|
sharedLine = person.sharedLine;
|
||||||
mailboxExt = if person.mailbox then person.extension else null;
|
mailboxExt = if person.mailbox then person.extension else null;
|
||||||
}) person.phones
|
}) person.phones
|
||||||
) {} cfg.persons;
|
) {} cfg.persons;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ pkgs.linkFarm "voip-tftp-root" (
|
||||||
lib.optionals m.hasProvisioning (
|
lib.optionals m.hasProvisioning (
|
||||||
let
|
let
|
||||||
t = templates.${phone.model};
|
t = templates.${phone.model};
|
||||||
familyLineEnabled = hasTrunk && phone.personKey != null;
|
familyLineEnabled = hasTrunk && phone.personKey != null && phone.sharedLine;
|
||||||
intercomLineIndex = if familyLineEnabled then 3 else 2;
|
intercomLineIndex = if familyLineEnabled then 3 else 2;
|
||||||
|
|
||||||
files = t.mkFiles ({
|
files = t.mkFiles ({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue