feat: add json based phonebook
This commit is contained in:
parent
ac4dc82594
commit
1de9a8ba91
5 changed files with 18 additions and 12 deletions
|
|
@ -147,6 +147,7 @@ in {
|
||||||
|
|
||||||
extensions = {
|
extensions = {
|
||||||
"*99" = { mode = "page"; displayName = "Durchsage an alle"; };
|
"*99" = { mode = "page"; displayName = "Durchsage an alle"; };
|
||||||
|
"*100" = { mode = "all"; displayName = "Alle rufen"; };
|
||||||
# custom app extension example:
|
# custom app extension example:
|
||||||
# "*00" = { mode = "app"; displayName = "Echo test"; app = "Echo()"; };
|
# "*00" = { mode = "app"; displayName = "Echo test"; app = "Echo()"; };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -281,9 +281,9 @@ let
|
||||||
|
|
||||||
# Page and app extensions from cfg.extensions
|
# Page and app extensions from cfg.extensions
|
||||||
+ "\n" + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
|
+ "\n" + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
|
||||||
if extCfg.mode == "page"
|
if extCfg.mode == "page" then "exten => ${ext},1,Page(${allPageEndpoints},i,120)"
|
||||||
then "exten => ${ext},1,Page(${allPageEndpoints},i,120)"
|
else if extCfg.mode == "all" then "exten => ${ext},1,Dial(${allL2Endpoints},30)"
|
||||||
else "exten => ${ext},1,${extCfg.app}"
|
else "exten => ${ext},1,${extCfg.app}"
|
||||||
) cfg.extensions)
|
) cfg.extensions)
|
||||||
|
|
||||||
# Auto-generated intercom extensions
|
# Auto-generated intercom extensions
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,9 @@ let
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Extension</th><th>Name</th><th>Type</th><th>Detail</th></tr>
|
<tr><th>Extension</th><th>Name</th><th>Type</th><th>Detail</th></tr>
|
||||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
|
||||||
let detail = if extCfg.mode == "page" then "all phones" else extCfg.app; in
|
let detail = if extCfg.mode == "page" then "all phones"
|
||||||
|
else if extCfg.mode == "all" then "all shared-line phones"
|
||||||
|
else extCfg.app; in
|
||||||
''<tr><td><code>${ext}</code></td><td>${extCfg.displayName}</td><td>${extCfg.mode}</td><td><code>${detail}</code></td></tr>''
|
''<tr><td><code>${ext}</code></td><td>${extCfg.displayName}</td><td>${extCfg.mode}</td><td><code>${detail}</code></td></tr>''
|
||||||
) cfg.extensions)}
|
) cfg.extensions)}
|
||||||
${lib.concatStringsSep "\n" (map (ic:
|
${lib.concatStringsSep "\n" (map (ic:
|
||||||
|
|
|
||||||
|
|
@ -315,12 +315,13 @@ in {
|
||||||
type = lib.types.attrsOf (lib.types.submodule {
|
type = lib.types.attrsOf (lib.types.submodule {
|
||||||
options = {
|
options = {
|
||||||
mode = lib.mkOption {
|
mode = lib.mkOption {
|
||||||
type = lib.types.enum [ "page" "app" ];
|
type = lib.types.enum [ "page" "all" "app" ];
|
||||||
default = "page";
|
default = "page";
|
||||||
description = ''
|
description = ''
|
||||||
Extension mode:
|
Extension mode:
|
||||||
- "page": one-way announcement to all phones
|
- "page": one-way announcement to all intercom-capable phones
|
||||||
- "app": custom Asterisk dialplan application
|
- "all": two-way call ringing all shared-line phones (allL2Endpoints)
|
||||||
|
- "app": custom Asterisk dialplan application
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
displayName = lib.mkOption {
|
displayName = lib.mkOption {
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@ let
|
||||||
|
|
||||||
personContacts = lib.mapAttrsToList (_key: person:
|
personContacts = lib.mapAttrsToList (_key: person:
|
||||||
lib.filterAttrs (_: v: v != null) {
|
lib.filterAttrs (_: v: v != null) {
|
||||||
displayName = person.displayName;
|
displayName = person.displayName;
|
||||||
extension = person.extension;
|
extension = person.extension;
|
||||||
|
sipUsernames = lib.attrNames person.phones;
|
||||||
intercomExtension =
|
intercomExtension =
|
||||||
if cfg.intercomPrefix != null && extensionHasIntercom person.extension
|
if cfg.intercomPrefix != null && extensionHasIntercom person.extension
|
||||||
then "${cfg.intercomPrefix}${person.extension}"
|
then "${cfg.intercomPrefix}${person.extension}"
|
||||||
|
|
@ -19,10 +20,11 @@ let
|
||||||
}
|
}
|
||||||
) cfg.persons;
|
) cfg.persons;
|
||||||
|
|
||||||
sharedPhoneContacts = lib.mapAttrsToList (_key: phone:
|
sharedPhoneContacts = lib.mapAttrsToList (key: phone:
|
||||||
lib.filterAttrs (_: v: v != null) {
|
lib.filterAttrs (_: v: v != null) {
|
||||||
displayName = phone.displayName;
|
displayName = phone.displayName;
|
||||||
extension = phone.extension;
|
extension = phone.extension;
|
||||||
|
sipUsernames = [ key ];
|
||||||
intercomExtension =
|
intercomExtension =
|
||||||
if cfg.intercomPrefix != null && models.${phone.model}.hasIntercom
|
if cfg.intercomPrefix != null && models.${phone.model}.hasIntercom
|
||||||
then "${cfg.intercomPrefix}${phone.extension}"
|
then "${cfg.intercomPrefix}${phone.extension}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue