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