Fix fax forward so it can use the fax queue.

This commit is contained in:
FusionPBX 2022-04-30 20:39:15 -06:00 committed by GitHub
parent bac66f75ac
commit eeba3eb66f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 117 additions and 77 deletions

View File

@ -235,7 +235,7 @@ if (!function_exists('fax_split_dtmf')) {
$caller_id_name = $_REQUEST["caller_id_name"];
$caller_id_number = $_REQUEST["caller_id_number"];
$fax_relay = $_REQUEST["retry"];
$mailfrom_address = $_REQUEST["mailfrom_address"];
$mail_from_address = $_REQUEST["mailfrom_address"];
}
else {
$tmp_array = explode("=", $_SERVER["argv"][1]);
@ -275,14 +275,14 @@ if (!function_exists('fax_split_dtmf')) {
unset($tmp_array);
$tmp_array = explode("=", $_SERVER["argv"][10]);
$mailfrom_address = $tmp_array[1];
$mail_from_address = $tmp_array[1];
unset($tmp_array);
//$tmp_array = explode("=", $_SERVER["argv"][10]);
//$destination_number = $tmp_array[1];
//unset($tmp_array);
}
$mailto_address = $fax_email;
$mail_to_address = $fax_email;
//get the fax file name (only) if a full path
$fax_path = pathinfo($fax_file);
@ -324,7 +324,7 @@ if (!function_exists('fax_split_dtmf')) {
$sql = "select * from v_fax ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and fax_extension = :fax_extension ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_extension'] = $fax_extension;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
@ -353,7 +353,7 @@ if (!function_exists('fax_split_dtmf')) {
//used for debug
echo "fax_prefix: $fax_prefix\n";
echo "mailto_adress: $mailto_address\n";
echo "mail_to_adress: $mail_to_address\n";
echo "fax_email: $fax_email\n";
echo "fax_extension: $fax_extension\n";
echo "fax_name: $fax_file_only\n";
@ -378,8 +378,45 @@ if (!function_exists('fax_split_dtmf')) {
$fax_forward_number = $fax_prefix.$tmp[0];
}
if (isset($fax_forward_number) && strlen($fax_forward_number) > 0) {
//show info
echo "fax_forward_number: $fax_forward_number\n";
if (strlen($fax_forward_number) > 0) {
//add fax to the fax queue or send it directly
if ($_SESSION['fax_queue']['enabled']['boolean']) {
//build an array to add the fax to the queue
$array['fax_queue'][0]['fax_queue_uuid'] = uuid();
$array['fax_queue'][0]['domain_uuid'] = $domain_uuid;
$array['fax_queue'][0]['fax_uuid'] = $fax_uuid;
$array['fax_queue'][0]['fax_date'] = 'now()';
$array['fax_queue'][0]['hostname'] = gethostname();
$array['fax_queue'][0]['fax_caller_id_name'] = $fax_caller_id_name;
$array['fax_queue'][0]['fax_caller_id_number'] = $fax_caller_id_number;
$array['fax_queue'][0]['fax_number'] = $fax_forward_number;
$array['fax_queue'][0]['fax_prefix'] = $fax_prefix;
$array['fax_queue'][0]['fax_email_address'] = $mail_to_address;
$array['fax_queue'][0]['fax_file'] = $fax_file;
$array['fax_queue'][0]['fax_status'] = 'waiting';
$array['fax_queue'][0]['fax_retry_count'] = 0;
$array['fax_queue'][0]['fax_accountcode'] = $fax_accountcode;
//add temporary permisison
$p = new permissions;
$p->add('fax_queue_add', 'temp');
//save the data
$database = new database;
$database->app_name = 'fax queue';
$database->app_uuid = '3656287f-4b22-4cf1-91f6-00386bf488f4';
$database->save($array);
//remove temporary permisison
$p->delete('fax_queue_add', 'temp');
//add message to show in the browser
message::add($text['confirm-queued']);
}
else {
fax_split_dtmf($fax_forward_number, $fax_dtmf);
$fax_send_mode = $_SESSION['fax']['send_mode']['text'];
@ -387,7 +424,7 @@ if (!function_exists('fax_split_dtmf')) {
$fax_send_mode = 'direct';
}
$route_array = outbound_route_to_bridge($_SESSION['domain_uuid'], $fax_forward_number);
$route_array = outbound_route_to_bridge($domain_uuid, $fax_forward_number);
if (count($route_array) == 0) {
//send the internal call to the registered extension
$fax_uri = "user/".$fax_forward_number."@".$domain_name;
@ -402,11 +439,12 @@ if (!function_exists('fax_split_dtmf')) {
}
}
//build the dial string
$dial_string = "absolute_codec_string='PCMU,PCMA',";
$dial_string .= "accountcode='" . $fax_accountcode . "',";
$dial_string .= "sip_h_X-accountcode='" . $fax_accountcode . "',";
$dial_string .= "domain_uuid=" . $_SESSION["domain_uuid"] . ",";
$dial_string .= "domain_name=" . $_SESSION["domain_name"] . ",";
$dial_string .= "domain_uuid=" . $domain_uuid . ",";
$dial_string .= "domain_name=" . $domain_name . ",";
$dial_string .= "origination_caller_id_name='" . $fax_caller_id_name . "',";
$dial_string .= "origination_caller_id_number='" . $fax_caller_id_number . "',";
$dial_string .= "fax_ident='" . $fax_caller_id_number . "',";
@ -414,9 +452,10 @@ if (!function_exists('fax_split_dtmf')) {
$dial_string .= "fax_file='" . $fax_file . "',";
if ($fax_send_mode != 'queue') {
//add more ot the dial string
$dial_string .= $fax_variables;
$dial_string .= "mailto_address='" . $mailto_address . "',";
$dial_string .= "mailfrom_address='" . $mailfrom_address . "',";
$dial_string .= "mailto_address='" . $mail_to_address . "',";
$dial_string .= "mailfrom_address='" . $mail_from_address . "',";
$dial_string .= "fax_uri=" . $fax_uri . ",";
$dial_string .= "fax_retry_attempts=1" . ",";
$dial_string .= "fax_retry_limit=20" . ",";
@ -460,6 +499,7 @@ if (!function_exists('fax_split_dtmf')) {
}
}
}
}
//send the email
if (strlen($fax_email) > 0 && file_exists($fax_file)) {
@ -499,7 +539,7 @@ if (!function_exists('fax_split_dtmf')) {
}
//replace variables in email subject
$email_subject = str_replace('${domain_name}', $_SESSION['domain_name'], $email_subject);
$email_subject = str_replace('${domain_name}', $domain_name, $email_subject);
$email_subject = str_replace('${fax_file_name}', $fax_file_name, $email_subject);
$email_subject = str_replace('${fax_extension}', $fax_extension, $email_subject);
$email_subject = str_replace('${fax_messages}', $fax_messages, $email_subject);
@ -507,7 +547,7 @@ if (!function_exists('fax_split_dtmf')) {
$email_subject = str_replace('${fax_subject_tag}', $fax_email_inbound_subject_tag, $email_subject);
//replace variables in email body
$email_body = str_replace('${domain_name}', $_SESSION['domain_name'], $email_body);
$email_body = str_replace('${domain_name}', $domain_name, $email_body);
$email_body = str_replace('${fax_file_name}', $fax_file_name, $email_body);
$email_body = str_replace('${fax_extension}', $fax_extension, $email_body);
$email_body = str_replace('${fax_messages}', $fax_messages, $email_body);