Finish NoService and NightMode

This commit is contained in:
2026-03-26 21:02:52 -04:00
parent b078dceb66
commit c36774db3b
5 changed files with 32 additions and 5 deletions

View File

@@ -52,6 +52,7 @@
<application-list default="deny"> <application-list default="deny">
<!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case --> <!-- type attr can be "deny" or "allow" nothing defaults to opposite of the list default so allow in this case -->
<application name="info"/> <application name="info"/>
<application name="answer"/>
<application name="hangup"/> <application name="hangup"/>
<application name="bridge"/> <application name="bridge"/>
</application-list> </application-list>

View File

@@ -1,2 +1,3 @@
DATABASE_URL=postgres://freeswitch:T5NyU2NwQb5DD9oV@localhost/did_router DATABASE_URL=postgres://freeswitch:T5NyU2NwQb5DD9oV@localhost/did_router
SOUND_PATH=/usr/src/freeswitch_chris/sounds

View File

@@ -1,3 +1,5 @@
use dotenvy::dotenv;
use std::env;
use xml_builder::{XMLBuilder, XMLElement, XMLVersion}; use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
use super::database as db; use super::database as db;
use super::database::{DidTargetType, Did}; use super::database::{DidTargetType, Did};
@@ -26,17 +28,25 @@ pub fn external_number(_did: Did) -> XMLElement {
} }
pub fn no_service(_did: Did) -> XMLElement { pub fn no_service(_did: Did) -> XMLElement {
dotenv().ok();
let sound_path = env::var("SOUND_PATH").expect("SOUND_PATH must be set");
let no_service_path = format!("{}/no_service.wav", sound_path);
let mut work = XMLElement::new("work"); let mut work = XMLElement::new("work");
let mut playback = XMLElement::new("playback");
playback.add_attribute("name", "exten");
playback.add_attribute("file", "ivr/ivr-welcome_to_freeswitch.wav");
work.add_child(playback).unwrap(); add_playback(&mut work, &no_service_path);
work work
} }
pub fn night_mode(_did: Did) -> XMLElement { pub fn night_mode(_did: Did) -> XMLElement {
let work = XMLElement::new("work"); dotenv().ok();
let sound_path = env::var("SOUND_PATH").expect("SOUND_PATH must be set");
let night_mode_path = format!("{}/night_mode.wav", sound_path);
let mut work = XMLElement::new("work");
add_playback(&mut work, &night_mode_path);
work work
} }
@@ -45,6 +55,21 @@ pub fn custom_message(_did: Did) -> XMLElement {
work work
} }
pub fn add_playback(work: &mut XMLElement ,file_path: &str) {
let mut answer = XMLElement::new("execute");
answer.add_attribute("application", "answer");
work.add_child(answer).unwrap();
let mut playback = XMLElement::new("playback");
playback.add_attribute("name", "exten");
playback.add_attribute("file", &file_path);
work.add_child(playback).unwrap();
let mut hangup = XMLElement::new("execute");
hangup.add_attribute("application", "hangup");
work.add_child(hangup).unwrap();
}
pub fn route_call(did: String) -> Vec<u8> { pub fn route_call(did: String) -> Vec<u8> {
let d = db::get_did_by(&did).unwrap(); let d = db::get_did_by(&did).unwrap();
let mut xml = XMLBuilder::new() let mut xml = XMLBuilder::new()

BIN
sounds/night_mode.wav Normal file

Binary file not shown.

BIN
sounds/no_service.wav Normal file

Binary file not shown.