|
|
|
|
@ -74,29 +74,10 @@ sub receive :Chained('list') :PathPart('receive') :Args(0) {
|
|
|
|
|
die "no_subscriber_found";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $pcc_url = $c->config->{pcc}->{url};
|
|
|
|
|
my $pcc_timeout = $c->config->{pcc}->{timeout};
|
|
|
|
|
my $pcc_enabled = 0;
|
|
|
|
|
my ($pcc_uuid, $pcc_token);
|
|
|
|
|
my $smsc_peer = 'default';
|
|
|
|
|
UUID::generate($pcc_uuid);
|
|
|
|
|
UUID::unparse($pcc_uuid, $pcc_token);
|
|
|
|
|
my $fwd_pref_rs = NGCP::Panel::Utils::Preferences::get_usr_preference_rs(
|
|
|
|
|
c => $c, attribute => 'party_call_control',
|
|
|
|
|
prov_subscriber => $prov_dbalias->subscriber,
|
|
|
|
|
);
|
|
|
|
|
if($fwd_pref_rs && $fwd_pref_rs->first && $fwd_pref_rs->first->value) {
|
|
|
|
|
$pcc_enabled = 1;
|
|
|
|
|
} else {
|
|
|
|
|
$fwd_pref_rs = NGCP::Panel::Utils::Preferences::get_dom_preference_rs(
|
|
|
|
|
c => $c, attribute => 'party_call_control',
|
|
|
|
|
prov_domain => $prov_dbalias->domain,
|
|
|
|
|
);
|
|
|
|
|
if($fwd_pref_rs && $fwd_pref_rs->first && $fwd_pref_rs->first->value) {
|
|
|
|
|
$pcc_enabled = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$c->log->info("pcc is set to $pcc_enabled for prov subscriber id " . $prov_dbalias->subscriber_id);
|
|
|
|
|
|
|
|
|
|
my $smsc_peer_rs = NGCP::Panel::Utils::Preferences::get_dom_preference_rs(
|
|
|
|
|
c => $c, attribute => 'smsc_peer',
|
|
|
|
|
@ -200,7 +181,7 @@ sub receive :Chained('list') :PathPart('receive') :Args(0) {
|
|
|
|
|
$dst =~ s/^sip:(.+)\@.+$/$1/;
|
|
|
|
|
$c->log->debug(">>>> forward sms to $dst");
|
|
|
|
|
|
|
|
|
|
my $pcc_status = $pcc_enabled ? "pending" : "none";
|
|
|
|
|
my $pcc_status = "pending";
|
|
|
|
|
my $fwd_item = NGCP::Panel::Utils::SMS::add_journal_record(
|
|
|
|
|
c => $c,
|
|
|
|
|
prov_subscriber => $prov_dbalias->subscriber,
|
|
|
|
|
@ -216,40 +197,16 @@ sub receive :Chained('list') :PathPart('receive') :Args(0) {
|
|
|
|
|
status => $pcc_status,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if($pcc_enabled && $pcc_url) {
|
|
|
|
|
try {
|
|
|
|
|
my $ret = NGCP::Panel::Utils::PartyCallControl::dispatch(
|
|
|
|
|
c => $c,
|
|
|
|
|
url => $pcc_url,
|
|
|
|
|
timeout => $pcc_timeout,
|
|
|
|
|
id => $fwd_item->id,
|
|
|
|
|
from => $from,
|
|
|
|
|
to => $to,
|
|
|
|
|
type => "sms",
|
|
|
|
|
text => $text,
|
|
|
|
|
token => $pcc_token,
|
|
|
|
|
);
|
|
|
|
|
unless($ret) {
|
|
|
|
|
$c->log->error("failed to dispatch pcc request");
|
|
|
|
|
$fwd_item->update({ pcc_status => "failed" });
|
|
|
|
|
}
|
|
|
|
|
} catch($e) {
|
|
|
|
|
$c->log->error("failed to dispatch pcc request: $e");
|
|
|
|
|
$fwd_item->update({ pcc_status => "failed" });
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
# no 3rd party call control, feed back into kannel
|
|
|
|
|
my $error_msg;
|
|
|
|
|
NGCP::Panel::Utils::SMS::send_sms(
|
|
|
|
|
c => $c,
|
|
|
|
|
smsc_peer => $smsc_peer,
|
|
|
|
|
caller => $to, # use the original to as new from
|
|
|
|
|
callee => $dst,
|
|
|
|
|
text => $text,
|
|
|
|
|
coding => $coding,
|
|
|
|
|
err_code => sub {$error_msg = shift;},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
my $error_msg;
|
|
|
|
|
NGCP::Panel::Utils::SMS::send_sms(
|
|
|
|
|
c => $c,
|
|
|
|
|
smsc_peer => $smsc_peer,
|
|
|
|
|
caller => $to, # use the original to as new from
|
|
|
|
|
callee => $dst,
|
|
|
|
|
text => $text,
|
|
|
|
|
coding => $coding,
|
|
|
|
|
err_code => sub {$error_msg = shift;},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|