Compare commits
2 commits
bf60fcce98
...
1de9a8ba91
| Author | SHA1 | Date | |
|---|---|---|---|
| 1de9a8ba91 | |||
| ac4dc82594 |
6 changed files with 66 additions and 8 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:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ let
|
|||
greetingDirs = import ./asterisk/greetings.nix { inherit lib pkgs cfg; };
|
||||
confFiles = import ./asterisk/default.nix { inherit lib cfg models allPhones intercomEntries mohDirs greetingDirs; };
|
||||
|
||||
directory = import ./provisioning/directory.nix { inherit lib pkgs cfg allPhones intercomEntries; };
|
||||
directory = import ./provisioning/directory.nix { inherit lib pkgs cfg allPhones intercomEntries; };
|
||||
directoryJson = import ./provisioning/directory-json.nix { inherit lib pkgs cfg models allPhones; };
|
||||
provisioningRoot = import ./provisioning/default.nix { inherit lib pkgs cfg models allPhones; };
|
||||
|
||||
diagram = import ./dashboard.nix { inherit lib pkgs cfg models allPhones intercomEntries; };
|
||||
|
|
@ -87,6 +88,7 @@ in {
|
|||
"= /directory.xml" = { alias = "${directory.menuFile}"; extraConfig = "default_type text/xml;"; };
|
||||
"= /directory-list.xml" = { alias = "${directory.listFile}"; extraConfig = "default_type text/xml;"; };
|
||||
"= /intercom.xml" = { alias = "${directory.intercomFile}"; extraConfig = "default_type text/xml;"; };
|
||||
"= /contacts.json" = { alias = "${directoryJson}"; extraConfig = ''default_type application/json; add_header Access-Control-Allow-Origin "*";''; };
|
||||
"/" = {
|
||||
root = "${diagram.webRoot}";
|
||||
extraConfig = lib.optionalString (!hasRuntimeSecrets) "index index.html;";
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
52
modules/voip/provisioning/directory-json.nix
Normal file
52
modules/voip/provisioning/directory-json.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{ lib, pkgs, cfg, models, allPhones }:
|
||||
|
||||
let
|
||||
# Does any provisioned phone on this extension support intercom?
|
||||
extensionHasIntercom = ext:
|
||||
lib.any (phone: phone.extension == ext && models.${phone.model}.hasIntercom)
|
||||
(lib.attrValues allPhones);
|
||||
|
||||
personContacts = lib.mapAttrsToList (_key: person:
|
||||
lib.filterAttrs (_: v: v != null) {
|
||||
displayName = person.displayName;
|
||||
extension = person.extension;
|
||||
sipUsernames = lib.attrNames person.phones;
|
||||
intercomExtension =
|
||||
if cfg.intercomPrefix != null && extensionHasIntercom person.extension
|
||||
then "${cfg.intercomPrefix}${person.extension}"
|
||||
else null;
|
||||
mailboxCheckExtension =
|
||||
if person.mailbox then "*97" else null;
|
||||
}
|
||||
) cfg.persons;
|
||||
|
||||
sharedPhoneContacts = lib.mapAttrsToList (key: phone:
|
||||
lib.filterAttrs (_: v: v != null) {
|
||||
displayName = phone.displayName;
|
||||
extension = phone.extension;
|
||||
sipUsernames = [ key ];
|
||||
intercomExtension =
|
||||
if cfg.intercomPrefix != null && models.${phone.model}.hasIntercom
|
||||
then "${cfg.intercomPrefix}${phone.extension}"
|
||||
else null;
|
||||
}
|
||||
) cfg.sharedPhones;
|
||||
|
||||
specialExtensions = lib.mapAttrsToList (ext: extCfg: {
|
||||
displayName = extCfg.displayName;
|
||||
extension = ext;
|
||||
mode = extCfg.mode;
|
||||
}) cfg.extensions;
|
||||
|
||||
directory = {
|
||||
version = 1;
|
||||
contacts = personContacts ++ sharedPhoneContacts;
|
||||
specialExtensions = specialExtensions;
|
||||
} // lib.optionalAttrs (cfg.sharedMailbox != null) {
|
||||
sharedMailbox = {
|
||||
inherit (cfg.sharedMailbox) displayName checkExtension;
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
pkgs.writeText "contacts.json" (builtins.toJSON directory)
|
||||
Loading…
Reference in a new issue