Fix local fax calls

Use loopback for sending local calls to other domains.
This commit is contained in:
FusionPBX 2024-10-21 16:53:10 -06:00 committed by GitHub
parent 55ba425b57
commit 8d2aefa41e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 58 additions and 39 deletions

View File

@ -61,6 +61,9 @@
exit;
}
//connect to the database
$database = new database;
//shutdown call back function
function shutdown() {
//when the fax status is still sending
@ -156,7 +159,6 @@
$sql .= "where fax_queue_uuid = :fax_queue_uuid ";
$sql .= "and q.domain_uuid = d.domain_uuid and f.fax_uuid = q.fax_uuid";
$parameters['fax_queue_uuid'] = $fax_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$fax_queue_uuid = $row['fax_queue_uuid'];
@ -261,13 +263,37 @@
$fax_options = "fax_use_ecm=true,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=true";
}
else {
//try the user defineable method again
//try the user definable method again
$fax_options = '';
foreach($setting->get('fax','variable') as $variable) {
$fax_options .= $variable.",";
}
}
//extract fax_dtmf from the fax number
fax_split_dtmf($fax_number, $fax_dtmf);
//get the fax toll allow
if (!empty($fax_toll_allow)) {
$channel_variables["toll_allow"] = $fax_toll_allow;
}
//check to see if the destination number is local
$sql = "select count(destination_uuid) ";
$sql .= "from v_destinations ";
$sql .= "where (";
$sql .= " destination_number = :destination_number ";
$sql .= " or concat(destination_prefix, destination_number) = :destination_number ";
$sql .= " or concat(destination_trunk_prefix, destination_number) = :destination_number ";
$sql .= " or concat(destination_area_code, destination_number) = :destination_number ";
$sql .= " or concat(destination_prefix, destination_area_code, destination_number) = :destination_number ";
$sql .= ")";
$parameters['destination_number'] = $fax_number;
$destination_count = $database->select($sql, $parameters, 'column');
if ($destination_count > 0) {
$route_array[] = 'loopback/'.$fax_number.'/public';
}
//define the fax file
$common_variables = '';
$common_variables = "accountcode='" . escape_quote($fax_accountcode) . "',";
@ -276,50 +302,47 @@
$common_variables .= "domain_name=" . $domain_name . ",";
$common_variables .= "origination_caller_id_name='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "origination_caller_id_number=" . $fax_caller_id_number . ",";
$common_variables .= "fax_ident='" . escape_quote($fax_caller_id_number) . "',";
$common_variables .= "fax_header='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "fax_file='" . escape_quote($fax_file) . "',";
//extract fax_dtmf from the fax number
fax_split_dtmf($fax_number, $fax_dtmf);
$common_variables .= "fax_ident='" . escape_quote($fax_caller_id_number) . "',";
$common_variables .= "fax_header='" . escape_quote($fax_caller_id_name) . "',";
$common_variables .= "fax_file='" . escape_quote($fax_file) . "',";
//prepare the fax command
if (!empty($fax_toll_allow)) {
$channel_variables["toll_allow"] = $fax_toll_allow;
}
$route_array = outbound_route_to_bridge($domain_uuid, $fax_prefix . $fax_number, $channel_variables);
if (count($route_array) == 0) {
//check for valid extension
$sql = "select count(extension_uuid) ";
$sql .= "from v_extensions ";
$sql .= "where extension = :fax_number ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_number'] = $fax_number;
$database = new database;
$extension_count = $database->select($sql, $parameters, 'column');
if ($extension_count > 0) {
//send the internal call to the registered extension
$route_array[] = "user/".$fax_number."@".$domain_name;
}
else {
$fax_status = 'failed';
if (empty($route_array)) {
$route_array = outbound_route_to_bridge($domain_uuid, $fax_prefix . $fax_number, $channel_variables);
if (count($route_array) == 0) {
//check for valid extension
$sql = "select count(extension_uuid) ";
$sql .= "from v_extensions ";
$sql .= "where extension = :fax_number ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_number'] = $fax_number;
$extension_count = $database->select($sql, $parameters, 'column');
if ($extension_count > 0) {
//send the internal call to the registered extension
$route_array[] = "user/".$fax_number."@".$domain_name;
}
else {
$fax_status = 'failed';
}
}
}
//set the origination uuid
$origination_uuid = uuid();
if (!is_uuid(origination_uuid)) {
$origination_uuid = uuid();
}
//build a list of fax variables
$dial_string = $common_variables;
$dial_string .= $fax_options.",";
$dial_string .= "origination_uuid=" . $origination_uuid. ",";
$dial_string .= "fax_uuid=" . $fax_uuid. ",";
$dial_string .= "fax_queue_uuid=" . $fax_queue_uuid. ",";
$dial_string .= "mailto_address='" . $fax_email_address . "',";
$dial_string .= "origination_uuid=" . $origination_uuid . ",";
$dial_string .= "fax_uuid=" . $fax_uuid . ",";
$dial_string .= "fax_queue_uuid=" . $fax_queue_uuid . ",";
$dial_string .= "mailto_address='" . $fax_email_address . "',";
$dial_string .= "mailfrom_address='" . $email_from_address . "',";
$dial_string .= "fax_retry_attempts=" . $fax_retry_count . ",";
$dial_string .= "fax_retry_limit=" . $retry_limit . ",";
$dial_string .= "fax_retry_attempts=" . $fax_retry_count . ",";
$dial_string .= "fax_retry_limit=" . $retry_limit . ",";
//$dial_string .= "fax_retry_sleep=180,";
$dial_string .= "fax_verbose=true,";
//$dial_string .= "fax_use_ecm=off,";
@ -369,7 +392,6 @@
$p->add('fax_queue_edit', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array, false);
@ -413,7 +435,6 @@
$parameters['template_language'] = $language_code;
$parameters['template_category'] = 'fax';
$parameters['template_type'] = 'html';
$database = new database;
$fax_templates = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
}
@ -465,7 +486,6 @@
$sql .= "from v_fax_logs ";
$sql .= "where fax_log_uuid = :fax_log_uuid ";
$parameters['fax_log_uuid'] = $fax_log_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$fax_success = $row['fax_success'];
@ -587,7 +607,6 @@
$p->add('fax_queue_edit', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array, false);