MT#6969 Trigger device resync via SIP if online

If we find a registration for the subscriber on the device, we trigger
a resync via SIP.
ipeshinskaya/InvoiceTemplate6
Andreas Granig 11 years ago
parent b892c720f5
commit 18467405b0

@ -1289,7 +1289,36 @@ sub pbx_device_sync :Chained('pbx_device_base') :PathPart('sync') :Args(0) {
my $form = NGCP::Panel::Form::Customer::PbxFieldDeviceSync->new;
my $posted = ($c->req->method eq 'POST');
# TODO: if registered, we could try taking the ip from location?
my $dev = $c->stash->{pbx_device};
foreach my $line($dev->autoprov_field_device_lines->search({
line_type => 'private',
})->all) {
my $sub = $line->provisioning_voip_subscriber;
next unless($sub);
my $reg_rs = $c->model('DB')->resultset('location')->search({
username => $sub->username,
});
if($c->config->{features}->{multidomain}) {
$reg_rs = $reg_rs->search({
domain => $sub->domain->domain,
});
}
my $uri = $sub->username . '@' . $sub->domain->domain;
if($reg_rs->count) {
$c->log->debug("trigger device resync for $uri as it is registered");
my @cmd_args = ($c->config->{cloudpbx}->{sync},
$sub->username, $sub->domain->domain,
$sub->password);
my $out = capturex([0], "sh", @cmd_args);
$c->log->debug(">>>>>>>>>>>> got output:\n$out");
}
$c->flash(messages => [{type => 'success', text => $c->loc('Successfully triggered config reload via SIP') }]);
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/customer/details', [ $c->req->captures->[0] ]));
return;
}
my $params = {};
$form->process(
@ -1302,7 +1331,6 @@ sub pbx_device_sync :Chained('pbx_device_base') :PathPart('sync') :Args(0) {
$c->flash(messages => [{type => 'success', text => $c->loc('Successfully redirected request to device') }]);
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/customer/details', [ $c->req->captures->[0] ]));
}
my $dev = $c->stash->{pbx_device};
my $schema = $c->config->{deviceprovisioning}->{secure} ? 'https' : 'http';
my $host = $c->config->{deviceprovisioning}->{host} // $c->req->uri->host;

@ -36,6 +36,10 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{
ip 127.0.0.1
</faxserver>
<cloudpbx>
sync "sh /etc/ngcp-panel/check-sync/check-sync"
</cloudpbx>
<fees_csv>
element_order source
element_order destination

Loading…
Cancel
Save