MT#21685 send fax support for carrier environment

* send fax to a remote proxy if defined, otherwise queue it locally
    * when queuing send fax remotely check if the host:port is alive

Change-Id: I29f9c32c784dccbb74d24ef4ef1ab0dc09d0a1ae
changes/45/7445/5
Kirill Solomko 9 years ago
parent b821f24ee7
commit 4bc81ed151

@ -6,6 +6,7 @@ use File::Slurp;
use TryCatch;
use IPC::System::Simple qw/capture/;
use Data::Dumper;
use Net::Ping;
sub send_fax {
my (%args) = @_;
@ -26,6 +27,22 @@ sub send_fax {
my %sendfax_args = ();
if ($c->config->{faxserver}{hosts}) {
my @hosts = split(/,\s*/, $c->config->{faxserver}{hosts});
my $port = $c->config->{faxserver}{port};
my $ping = new Net::Ping('tcp', 1);
$ping->port_number($port);
do {
my $host = $hosts[rand @hosts];
if ($ping->ping($host)) {
$sendfax_args{host} = $host;
$sendfax_port{port} = $port;
}
@hosts = grep { $_ ne $host } @hosts;
} while (!$sendfax_args{host} && @hosts);
die "No alive proxy hosts to queue the send fax to" unless @hosts;
}
my $sender = 'webfax';
my $number;
if($subscriber->primary_number) {

Loading…
Cancel
Save