TT#18308 more detailed POST /api/faxes debug msgs

Change-Id: I6f5ba0878541cc6cb7694210e2c25e89bc670205
changes/74/14174/4
Rene Krenn 8 years ago
parent d6632b5178
commit f0d1350bba

@ -211,6 +211,7 @@ sub POST :Allow {
last unless $self->require_wellformed_json($c, 'application/json', $json_utf8 );
my $resource = JSON::from_json($json_utf8, { utf8 => 0 });
$resource->{faxfile} = $self->get_upload($c, 'faxfile');
$c->log->debug("upload received");
my $form = $self->get_form($c);
last unless $self->validate_form(
@ -219,6 +220,7 @@ sub POST :Allow {
form => $form,
exceptions => [qw/subscriber_id/],
);
$c->log->debug("form validated");
my $billing_subscriber = NGCP::Panel::Utils::API::Subscribers::get_active_subscriber($self, $c, $resource->{subscriber_id});
unless($billing_subscriber) {
$c->log->error("invalid subscriber id $$resource{subscriber_id} for fax send");
@ -234,6 +236,7 @@ sub POST :Allow {
last;
}
try {
$c->log->debug("contacting fax server");
my $output = NGCP::Panel::Utils::Fax::send_fax(
c => $c,
subscriber => $billing_subscriber,

@ -30,10 +30,12 @@ sub send_fax {
if ($c->config->{faxserver}{hosts}) {
my @hosts = split(/,\s*/, $c->config->{faxserver}{hosts});
my $port = $c->config->{faxserver}{port};
$c->log->debug("faxserver port $port hosts: " . join(',',@hosts));
my $ping = new Net::Ping('tcp', 1);
$ping->port_number($port);
do {
my $host = $hosts[rand @hosts];
$c->log->debug("pinging $host:$port");
if ($ping->ping($host)) {
$sendfax_args{host} = $host;
$sendfax_args{port} = $port;
@ -66,11 +68,14 @@ sub send_fax {
$sendfax_args{files} = [];
if($args{upload}){
push @{$sendfax_args{files}}, eval { $args{upload}->tempname };
$c->log->debug('error to retrieve tempfile of upload: ' . @_) if @_;
}
if($args{data}){
$sendfax_args{input} = [\$args{data}];
}
my $client = new NGCP::Fax;
use Data::Dumper;
$c->log->debug('invoke send_fax with args: ' . Dumper(\%sendfax_args));
$client->send_fax(\%sendfax_args);
$c->log->debug("webfax: res=$res;");
}

Loading…
Cancel
Save