MT#63479 Remove prosody support

Change-Id: I9d3e268450396c12e4058ac9394a80bb191d7635
mr14.1
Guillem Jover 5 months ago
parent f6246ba094
commit b6e2baa6c7

@ -17,7 +17,7 @@ sub allowed_methods{
}
sub api_description {
return 'Combined collection of conversation events (calls, voice mails, sms, faxes, xmpp messages).';
return 'Combined collection of conversation events (calls, voice mails, sms, faxes).';
};
sub query_params {
@ -51,7 +51,7 @@ sub query_params {
{
param => 'type',
description => 'Filter for conversation events of given types ("call", "voicemail", "sms", "fax", "xmpp"). Multiple types can be included by concatenating type strings, eg. "?type=call-voicemial".',
description => 'Filter for conversation events of given types ("call", "voicemail", "sms", "fax"). Multiple types can be included by concatenating type strings, eg. "?type=call-voicemial".',
},
{

@ -119,7 +119,7 @@ sub POST :Allow {
media_type => 'application/json',
);
last unless $resource;
my ($sip_reload, $xmpp_reload) = $self->check_reload($c, $resource);
my $sip_reload = $self->check_sip_reload($c, $resource);
my $form = $self->get_form($c);
last unless $self->validate_form(
@ -175,7 +175,6 @@ sub POST :Allow {
$guard->commit;
try {
$self->xmpp_domain_reload($c, $resource->{domain}) if $xmpp_reload;
NGCP::Panel::Utils::XMLDispatcher::sip_domain_reload($c, $resource->{domain}) if ($sip_reload);
} catch($e) {
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to activate domain. Domain was created", $e);

@ -74,7 +74,7 @@ sub DELETE :Allow {
my $domain = $self->item_by_id($c, $id);
last unless $self->resource_exists($c, domain => $domain);
my ($sip_reload, $xmpp_reload) = $self->check_reload($c, $c->req->params);
my $sip_reload = $self->check_sip_reload($c, $c->req->params);
if($c->user->roles eq "admin") {
} elsif($c->user->roles eq "reseller") {
@ -102,7 +102,6 @@ sub DELETE :Allow {
$guard->commit;
try {
$self->xmpp_domain_disable($c, $domain->domain) if $xmpp_reload;
NGCP::Panel::Utils::XMLDispatcher::sip_domain_reload($c) if $sip_reload;
} catch($e) {
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Failed to deactivate domain.", $e);

@ -30,8 +30,8 @@ __PACKAGE__->set_config({
});
sub api_description {
return 'Defines an actual user who can log into the web panel, register devices via SIP and/or '.
'XMPP and place and receive calls via SIP. A subscriber always belongs to a '.
return 'Defines an actual user who can log into the web panel, register devices via SIP '.
'and place and receive calls via SIP. A subscriber always belongs to a '.
'<a href="#customers">Customer</a> and is placed inside a <a href="#domains">Domain</a>.';
}

@ -9,7 +9,6 @@ use NGCP::Panel::Form;
use NGCP::Panel::Utils::Message;
use NGCP::Panel::Utils::Navigation;
use NGCP::Panel::Utils::Prosody;
use NGCP::Panel::Utils::Preferences;
use NGCP::Panel::Utils::XMLDispatcher;
@ -158,8 +157,6 @@ sub create :Chained('dom_list_restricted') :PathPart('create') :Args() {
}
}
NGCP::Panel::Utils::Prosody::activate_domain($c, $form->value->{domain})
unless($c->config->{features}->{debug});
delete $c->session->{created_objects}->{reseller};
$c->session->{created_objects}->{domain} = { id => $new_dom->id };
});
@ -314,8 +311,6 @@ sub delete_domain :Chained('base') :PathPart('delete') :Args(0) {
$prov_domain->voip_dom_preferences->delete;
$prov_domain->provisioning_voip_subscribers->delete;
$prov_domain->delete;
NGCP::Panel::Utils::Prosody::deactivate_domain($c, $domain)
unless($c->config->{features}->{debug});
});
} catch ($e) {
NGCP::Panel::Utils::Message::error(

@ -5,7 +5,7 @@ extends 'HTML::FormHandler';
has_field 'id' => (
type => 'PosInteger',
label => 'The original conversation record id - cdr id/voicemail id/sms id/fax journal record id/prosody message archive mgmt (mam) record id.',
label => 'The original conversation record id - cdr id/voicemail id/sms id/fax journal record id.',
required => 1,
);
@ -29,7 +29,7 @@ has_field 'start_time' => (
has_field 'type' => (
type => 'Text',
label => 'The conversation event type: call/voicemail/sms/fax/xmpp.',
label => 'The conversation event type: call/voicemail/sms/fax.',
required => 1,
);

@ -36,7 +36,7 @@ has_field 'display_name' => (
label => 'Display Name',
element_attr => {
rel => ['tooltip'],
title => ['The person\'s name, which is then used in XMPP contact lists or auto-provisioned phones, and which can be used as network-provided display name in SIP calls.']
title => ['The person\'s name, which is then used in auto-provisioned phones, and which can be used as network-provided display name in SIP calls.']
},
maxlength => 128,
);
@ -55,7 +55,7 @@ has_field 'username' => (
label => 'SIP Username',
element_attr => {
rel => ['tooltip'],
title => ['The username for SIP and XMPP services.']
title => ['The username for SIP services.']
},
);

@ -71,7 +71,7 @@ has_field 'username' => (
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The username for SIP and XMPP services.']
title => ['The username for SIP services.']
},
);
@ -100,7 +100,7 @@ has_field 'password' => (
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The password to authenticate for SIP and XMPP services.']
title => ['The password to authenticate for SIP services.']
},
);

@ -21,7 +21,7 @@ has_field 'display_name' => (
label => 'Display Name',
element_attr => {
rel => ['tooltip'],
title => ['The person\'s name, which is then used in XMPP contact lists or auto-provisioned phones, and which can be used as network-provided display name in SIP calls.']
title => ['The person\'s name, which is then used in auto-provisioned phones, and which can be used as network-provided display name in SIP calls.']
},
maxlength => 128,
);

@ -65,7 +65,7 @@ has_field 'username' => (
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The username for SIP and XMPP services.']
title => ['The username for SIP services.']
},
);
@ -94,7 +94,7 @@ has_field 'password' => (
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The password to authenticate for SIP and XMPP services.']
title => ['The password to authenticate for SIP services.']
},
);
@ -157,7 +157,7 @@ has_field 'display_name' => (
label => 'Display Name',
element_attr => {
rel => ['tooltip'],
title => ['The person\'s name, which is then used in XMPP contact lists or auto-provisioned phones, and which can be used as network-provided display name in SIP calls.']
title => ['The person\'s name, which is then used in auto-provisioned phones, and which can be used as network-provided display name in SIP calls.']
},
maxlength => 128,
);

@ -200,20 +200,16 @@ sub get_valid_patch_data {
return $json;
}
sub check_reload {
sub check_sip_reload {
my ($self, $c, $resource) = @_;
my ($sip, $xmpp) = (1,1);
my $sip = 1;
if (delete $resource->{_skip_sip_reload} || $c->config->{features}->{debug}) {
$sip = 0;
$c->log->debug("skipping SIP reload");
}
if (delete $resource->{_skip_xmpp_reload} || $c->config->{features}->{debug}) {
$xmpp = 0;
$c->log->debug("skipping XMPP reload");
}
return ($sip, $xmpp);
return $sip;
}
sub validate_form {

@ -43,7 +43,6 @@ my %enabled_conversations = (
voicemail => 1,
sms => 1,
fax => 1,
xmpp => 1,
);
my %call_fields = ();
@ -123,19 +122,11 @@ $fax_fields{caller_uuid} = 'me.caller_uuid';
$fax_fields{callee_uuid} = 'me.callee_uuid';
$fax_fields{call_id} = 'me.call_id';
my %xmpp_fields = ();
my $xmpp_fields_tied = tie(%xmpp_fields, 'Tie::IxHash');
$xmpp_fields{subscriber_id} = 'me.id';
$xmpp_fields{user} = 'me.user';
$xmpp_fields{with} = 'me.with';
$xmpp_fields{epoch} = 'me.epoch';
my $max_fields = scalar keys %call_fields;
$max_fields += scalar NGCP::Panel::Utils::CallList::get_suppression_id_colnames();
$max_fields = scalar keys %voicemail_fields if ((scalar keys %voicemail_fields) > $max_fields);
$max_fields = scalar keys %sms_fields if ((scalar keys %sms_fields) > $max_fields);
$max_fields = scalar keys %fax_fields if ((scalar keys %fax_fields) > $max_fields);
$max_fields = scalar keys %xmpp_fields if ((scalar keys %xmpp_fields) > $max_fields);
my $cdr_proto = NGCP::Panel::Utils::Generic::hash2obj(
@ -207,17 +198,6 @@ my $sms_proto = NGCP::Panel::Utils::Generic::hash2obj(
},
);
my $xmpp_proto = NGCP::Panel::Utils::Generic::hash2obj(
classname => 'xmpp_item',
accessors => {
%{_get_fields_names(\%xmpp_fields,$xmpp_fields_tied)},
get_column => sub {
my ($self,$colname) = @_;
return $self->{$colname};
},
},
);
sub get_list{
my ($self, $c) = @_;
#TODO: move to config and return to the SUPER (Entities) again
@ -282,7 +262,7 @@ sub _item_rs {
my $item_rs;
my $type_param = ((exists $params->{type}) ? ($params->{type} // '') : undef);
foreach my $type (qw(call voicemail sms fax xmpp)) {
foreach my $type (qw(call voicemail sms fax)) {
if ($enabled_conversations{$type} and ((not defined $type_param) or index(lc($type_param),$type) > -1)) {
my $sub_name = '_get_' . $type . '_rs';
my $rs = $self->$sub_name(
@ -692,100 +672,6 @@ sub _get_fax_rs {
}
sub _get_xmpp_rs {
my $self = shift;
my %params = @_;
my ($c,$uuid,$contract_id,$reseller_id,$params) = @params{qw/c uuid contract_id reseller_id params/};
my $rs = $c->model('DB')->resultset('provisioning_voip_subscribers')->search_rs(undef,{
#join => [ 'domain', 'sipwise_mam_user', 'sipwise_mam_with' ],
join => 'domain',
});
$rs = $self->_apply_timestamp_from_to(
rs => $rs,
params => $params,
col => 'epoch'
);
$rs = $self->apply_caller_filter(
rs => $rs,
params => $params,
col => 'user'
);
$rs = $self->apply_callee_filter(
rs => $rs,
params => $params,
col => 'with'
);
if ($reseller_id) {
$rs = $rs->search_rs({
'contact.reseller_id' => $reseller_id,
},{
join => { voip_subscriber => { contract => 'contact'} },
});
}
if ($contract_id) {
$rs = $rs->search({
'contract.id' => $contract_id,
},{
join => { voip_subscriber => 'contract' },
});
}
if ($uuid) {
$rs = $rs->search({
'me.uuid' => $uuid,
});
}
my $out_rs = $rs->search_rs(undef,{
join => 'sipwise_mam_user',
'+select' => [
{ '' => \'"out"', -as => 'direction' },
{ '' => 'sipwise_mam_user.id', -as => 'mam_id' },
{ '' => 'sipwise_mam_user.username', -as => 'user' },
{ '' => 'sipwise_mam_user.with', -as => 'with' },
{ '' => 'sipwise_mam_user.epoch', -as => 'epoch' },
],
'+as' => ['direction','mam_id','user','with','epoch'],
});
my $in_rs = $rs->search_rs(undef,{
join => 'sipwise_mam_with',
'+select' => [
{ '' => \'"in"', -as => 'direction' },
{ '' => 'sipwise_mam_with.id', -as => 'mam_id' },
{ '' => 'sipwise_mam_with.username', -as => 'user' },
{ '' => 'sipwise_mam_with.with', -as => 'with' },
{ '' => 'sipwise_mam_with.epoch', -as => 'epoch' },
],
'+as' => ['direction','mam_id','user','with','epoch'],
});
$self->_apply_direction(params => $params,
in => sub {
$rs = $in_rs;
},
out => sub {
$rs = $out_rs;
},
inout => sub {
$rs = $out_rs->union_all($in_rs);
},
);
return $rs->search(undef,{
select => [
{ '' => \'"xmpp"', -as => 'type' },
{ '' => 'mam_id', -as => 'id' },
{ '' => 'epoch', -as => 'timestamp' },
_get_select_list(\%xmpp_fields),
],
as => ['type','id','timestamp',_get_as_list(\%xmpp_fields),],
});
}
sub _get_select_list {
my ($fields,$min,$max) = @_;
@ -930,8 +816,6 @@ sub process_hal_resource {
}elsif('sms' eq $resource->{type}){
$resource = $item_accessors_hash;
#$resource->{start_time} = NGCP::Panel::Utils::DateTime::from_string($item_mock_obj->timestamp)->epoch;
}elsif('xmpp' eq $resource->{type}){
$resource = $item_accessors_hash;
}
#$c->log->debug(Dumper('resource'));
#$c->log->debug(Dumper($resource));
@ -1003,10 +887,6 @@ sub _get_fields_by_type{
$fields = \%fax_fields;
$fields_tied = $fax_fields_tied;
$proto = $fax_proto;
}elsif('xmpp' eq $type){
$fields = \%xmpp_fields;
$fields_tied = $xmpp_fields_tied;
$proto = $xmpp_proto;
}
return $fields,$fields_tied,$proto;
}
@ -1092,10 +972,6 @@ sub hal_links {
Data::HAL::Link->new(relation => 'ngcp:faxes', href => sprintf("/api/faxes/%d", $resource->{id})),
Data::HAL::Link->new(relation => 'ngcp:faxrecordings', href => sprintf("/api/faxrecordings/%d", $resource->{id})),
) : ()),
# todo - add xmpp mam rail:
#('xmpp' eq $item->{type} ? (
# Data::HAL::Link->new(relation => 'ngcp:xmpp', href => sprintf("/api/xmpp/%d", $item->{id})),
# ) : ()),
];
}

@ -10,7 +10,6 @@ use Data::HAL qw();
use Data::HAL::Link qw();
use HTTP::Status qw(:constants);
use JSON::Types;
use NGCP::Panel::Utils::Prosody;
sub get_form {
my ($self, $c) = @_;
@ -94,16 +93,6 @@ sub item_by_id {
return $item_rs->find($id);
}
sub xmpp_domain_reload {
my ($self, $c, $domain) = @_;
NGCP::Panel::Utils::Prosody::activate_domain($c, $domain);
}
sub xmpp_domain_disable {
my ($self, $c, $domain) = @_;
NGCP::Panel::Utils::Prosody::deactivate_domain($c, $domain);
}
=pod
# you can't update a domain per se, only its preferences!
sub update_item {

@ -14,7 +14,6 @@ use JSON::Types;
use Safe::Isa qw($_isa);
use Data::Validate::IP qw/is_ipv4 is_ipv6/;
use NGCP::Panel::Utils::Preferences;
use NGCP::Panel::Utils::Prosody;
sub get_form {
my ($self, $c) = @_;

@ -13,7 +13,6 @@ use HTTP::Status qw(:constants);
use JSON::Types;
use Test::More;
use NGCP::Panel::Utils::XMLDispatcher;
use NGCP::Panel::Utils::Prosody;
use NGCP::Panel::Utils::Subscriber;
sub get_form {

@ -14,7 +14,6 @@ use Test::More;
use POSIX qw(ceil);
use NGCP::Panel::Form;
use NGCP::Panel::Utils::XMLDispatcher;
use NGCP::Panel::Utils::Prosody;
use NGCP::Panel::Utils::Subscriber;
use NGCP::Panel::Utils::Events;
use NGCP::Panel::Utils::DateTime;

@ -176,10 +176,8 @@ sub localize {
$c->loc('The members (as SIP URIs) of the PBX hunt group.');
$c->loc('CLI of CloudPBX Pilot Subscriber');
$c->loc('The base CLI for the PBX extension.');
$c->loc('Export subscriber to shared XMPP Buddylist');
$c->loc('Export this subscriber into the shared XMPP buddy list for the customer.');
$c->loc('Network-Provided Display Name');
$c->loc('The network-provided display name used for XMPP contacts and optionally SIP outbound header manipulation.');
$c->loc('The network-provided display name used optionally for SIP outbound header manipulation.');
$c->loc('Customer Sound Set');
$c->loc('Customer specific Sound Set used for PBX auto-attendant prompts, customer-specific announcements etc.');
$c->loc('api test pref');
@ -193,7 +191,6 @@ sub localize {
$c->loc('Session Timers');
$c->loc('Internals');
$c->loc('Cloud PBX');
$c->loc('XMPP Settings');
return;
}
@ -371,7 +368,7 @@ sub form_strings {
$c->loc('Whether the subscriber can configure other subscribers within his Customer account.');
$c->loc('The fully qualified domain name (e.g. sip.example.org).');
$c->loc('Is superuser');
$c->loc('The username for SIP and XMPP services.');
$c->loc('The username for SIP services.');
$c->loc('Create Contact');
$c->loc('Interval charge');
$c->loc('Supports Busy Lamp Field');
@ -486,7 +483,7 @@ sub form_strings {
$c->loc('The main E.164 number (containing a cc, ac and sn attribute) used for inbound and outbound calls.');
$c->loc('From Pattern');
$c->loc('A unique identifier string (only alphanumeric chars and _).');
$c->loc('The person\'s name, which is then used in XMPP contact lists or auto-provisioned phones, and which can be used as network-provided display name in SIP calls.');
$c->loc('The person\'s name, which is then used in auto-provisioned phones, and which can be used as network-provided display name in SIP calls.');
$c->loc('Line/Key Range');
$c->loc('A POSIX regex matching against the full Request-URI (e.g. \'^sip:.+@example\.org$\' or \'^sip:431\')');
$c->loc('The status of the subscriber.');
@ -680,7 +677,7 @@ sub form_strings {
$c->loc('IP Address');
$c->loc('Notify Emails');
$c->loc('Description');
$c->loc('The password to authenticate for SIP and XMPP services.');
$c->loc('The password to authenticate for SIP services.');
$c->loc('Handle');
$c->loc('Delete Key');

@ -1,80 +0,0 @@
package NGCP::Panel::Utils::Prosody;
use Sipwise::Base;
use Net::Telnet;
sub activate_domain {
my ($c, $domain) = @_;
$domain = lc $domain;
my $t = Net::Telnet->new(Timeout => 5, ErrMode => 'die');
my $hosts = _load_servers($c);
my $ok = 1;
foreach my $host(@{ $hosts }) {
eval {
$t->open(Host => $host->{ip}, Port => $host->{port});
$t->waitfor('/http:\/\/prosody.im\/doc\/console/');
$t->print("host:activate('$domain')");
my ($res, $amatch) = $t->waitfor(
Match => '/(Result: \w+)|(Message: .+)/',
Timeout => 20
);
if($amatch =~ /Result:\s*true/) {
# fine
} else {
$ok = 0;
}
$t->print("quit");
};
if ($@) {
$ok = $@ =~ /problem connecting to/ ? $ok : 0;
}
}
return $ok if($ok);
return;
}
sub deactivate_domain {
my ($c, $domain) = @_;
$domain = lc $domain;
my $t = Net::Telnet->new(Timeout => 5, ErrMode => 'die');
my $hosts = _load_servers($c);
my $ok = 1;
foreach my $host(@{ $hosts }) {
eval {
$t->open(Host => $host->{ip}, Port => $host->{port});
$t->waitfor('/http:\/\/prosody.im\/doc\/console/');
$t->print("host:deactivate('$domain')");
my ($res, $amatch) = $t->waitfor(
Match => '/(Result: \w+)|(Message: .+)/',
Timeout => 20
);
if($amatch =~ /Result:\s*true/) {
# fine
} else {
$ok = 0;
}
$t->print("quit");
};
if ($@) {
$ok = $@ =~ /problem connecting to/ ? $ok : 0;
}
}
return $ok if($ok);
return;
}
sub _load_servers {
my ($c) = @_;
my $host_rs = $c->model('DB')->resultset('xmlgroups')
->search_rs({name => 'xmpp'})
->search_related('xmlhostgroups')->search_related('host');
return [map { +{ip => $_->ip, port => $_->port, path => $_->path,
id => $_->id} } $host_rs->all];
}
1;
# vim: set tabstop=4 expandtab:

@ -21,7 +21,7 @@ $fake_data->set_data_from_script({
});
$test_machine->DATA_ITEM_STORE($fake_data->process('conversations'));
my @TYPES = qw/call voicemail fax sms xmpp/;
my @TYPES = qw/call voicemail fax sms/;
foreach my $owner_param ( map {'?'.$_.'='.$test_machine->DATA_ITEM->{$_}}
qw/customer_id subscriber_id/

@ -147,36 +147,6 @@
is:
code: 200
#get conversations
-
name: get conversations
type: item
method: GET
path: '/${link}'
perl_code: !!perl/code |
{
my ($retained) = @_;
$retained->{link} = "/api/conversations/?customer_id=".$retained->{customer_id}."&type=xmpp&order_by=type";
}
conditions:
is:
code: 200
#get conversations
-
name: get conversations
type: item
method: GET
path: '/${link}'
perl_code: !!perl/code |
{
my ($retained) = @_;
$retained->{link} = "/api/conversations/?customer_id=".$retained->{customer_id}."&type=xmpp&order_by=timestamp";
}
conditions:
is:
code: 200
#get conversations
-
name: get conversations
@ -297,36 +267,6 @@
is:
code: 200
#get conversations
-
name: get conversations
type: item
method: GET
path: '/${link}'
perl_code: !!perl/code |
{
my ($retained) = @_;
$retained->{link} = "/api/conversations/?subscriber_id=".$retained->{subscriber_id}."&type=xmpp&order_by=type";
}
conditions:
is:
code: 200
#get conversations
-
name: get conversations
type: item
method: GET
path: '/${link}'
perl_code: !!perl/code |
{
my ($retained) = @_;
$retained->{link} = "/api/conversations/?subscriber_id=".$retained->{subscriber_id}."&type=xmpp&order_by=timestamp";
}
conditions:
is:
code: 200
#get conversations
-
name: get conversations

Loading…
Cancel
Save