diff --git a/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm b/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm index a93a1bdbef..cb0151ee67 100644 --- a/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm +++ b/lib/NGCP/Panel/Controller/API/VoicemailGreetings.pm @@ -43,10 +43,8 @@ sub query_params { my $c = shift; my %wheres = (); if( $c->config->{features}->{multidomain}) { - $wheres{'domain.id'} = { -ident => 'subscriber.domain_id' }; + $wheres{'domain.id'} = { -ident => 'voip_subscriber.domain_id' }; } - - my $h = return { 'voip_subscriber.id' => $q, %wheres, @@ -55,12 +53,12 @@ sub query_params { second => sub { my $q = shift; my $c = shift; - my @joins = (); + my $subscriber_join = 'voip_subscriber'; if( $c->config->{features}->{multidomain}) { - push @joins, 'domain' ; + $subscriber_join = { 'voip_subscriber' => 'domain' }; } return { - join => [{ subscriber => 'voip_subscriber' },@joins] + join => [{ 'mailboxuser' => { 'provisioning_voip_subscriber' => $subscriber_join }}] }; }, }, diff --git a/t/api-rest/api-voicemailgreetings.t b/t/api-rest/api-voicemailgreetings.t index 0428cb2f6c..f15f30523a 100644 --- a/t/api-rest/api-voicemailgreetings.t +++ b/t/api-rest/api-voicemailgreetings.t @@ -46,11 +46,15 @@ is($greeting->{content}->{subscriber_id}, $test_machine->DATA_ITEM->{json}->{sub ok($greeting->{content}->{dir} =~/^(?:unavail|busy)$/, "Check dir after creation."); is($greeting->{content}->{dir}, $test_machine->DATA_ITEM->{json}->{dir}, "Check dir after creation #2."); +$res = $test_machine->request_get('/api/voicemailgreetings/?subscriber_id='.$greeting->{content}->{subscriber_id}.'&type='.$greeting->{content}->{dir}); +$test_machine->http_code_msg(200, "check subscriber_id and type filters", $res); + $res = $test_machine->request_get($greeting->{location}, undef, { 'Accept' => 'audio/x-wav', }); $test_machine->http_code_msg(200, "check download voicemail greeting", $res); + my $expected_downloaded_name = "voicemail_".$greeting->{content}->{dir}."_".$greeting->{content}->{subscriber_id}.".wav"; is($res->filename, $expected_downloaded_name ,"Check downloaded file name: $expected_downloaded_name ."); ok(length($res->content)>0,"Check length of the downloaded file > 0 :".length($res->content)); @@ -98,19 +102,13 @@ if(ok($soxi_output =~/GSM/, "Check that we converted wav to GSM encoding:".$soxi greetingfile => [ dirname($0).'/resources/empty.wav' ], } ); $test_machine->http_code_msg(422, "check response code on put empty file", $res_put_empty, $content_put_empty); - diag("Check dirty file:"); - #btw - other vriant of tha put data - closer to stored. will be changed by Collection::encode_content - ($res_put_empty,$content_put_empty) = $test_machine->request_put( { - %{$test_machine->DATA_ITEM_STORE}, - greetingfile => [ dirname($0).'/resources/empty.wav' ], - } ); - $test_machine->http_code_msg(422, "check response code on put empty file", $res_put_empty, $content_put_empty); } $test_machine->check_bundle(); $test_machine->check_item_delete($greeting->{location}); - $test_machine->clear_test_data_all();#fake data aren't registered in this test machine, so they will stay. +undef $fake_data; +undef $test_machine; done_testing;