From 3b9f19b6c8dc30dbde394ebc5b589f7e8df3a73c Mon Sep 17 00:00:00 2001 From: Oleksandr Duts Date: Mon, 14 Mar 2022 13:18:24 +0200 Subject: [PATCH] TT#141101 UI/API fix custom_announcement upload * Ability to upload sound set file for custom_announcement. Change-Id: I51dbf3fd9b9820adfa8ebe186c63cf39383a76ee --- lib/NGCP/Panel/Role/API/SoundFiles.pm | 9 ++++++--- lib/NGCP/Panel/Utils/Sems.pm | 2 +- lib/NGCP/Panel/Utils/Sounds.pm | 4 +--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/NGCP/Panel/Role/API/SoundFiles.pm b/lib/NGCP/Panel/Role/API/SoundFiles.pm index 4a59778293..6bb3080447 100644 --- a/lib/NGCP/Panel/Role/API/SoundFiles.pm +++ b/lib/NGCP/Panel/Role/API/SoundFiles.pm @@ -157,15 +157,18 @@ sub update_item { }); my $handle; if($set->contract_id) { + my @group_names = qw/pbx music_on_hold digits custom_announcements/; $handle_rs = $handle_rs->search({ - 'group.name' => { 'in' => ['pbx', 'music_on_hold', 'digits'] }, + 'group.name' => { 'in' => \@group_names}, },{ join => 'group', }); $handle = $handle_rs->first; unless($handle) { - $c->log->error("invalid handle '$$resource{handle}', must be in group pbx, music_on_hold or digits for a customer sound set"); - $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Handle must be in group pbx, music_on_hold or digits for a customer sound set"); + my $must_be_in_string = sprintf("the sound file must be in one of the customer sound set groups: %s", + join(', ', @group_names)); + $c->log->error('invalid handle ' . $resource->{handle} . ' ' . $must_be_in_string); + $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Handle $must_be_in_string"); return; } } else { diff --git a/lib/NGCP/Panel/Utils/Sems.pm b/lib/NGCP/Panel/Utils/Sems.pm index 52764952cc..5a0f073171 100644 --- a/lib/NGCP/Panel/Utils/Sems.pm +++ b/lib/NGCP/Panel/Utils/Sems.pm @@ -317,7 +317,7 @@ sub clear_audio_cache { my @services; if ($group_name eq "pbx" ) { @services = (@pbx); - } elsif ($group_name =~ /^(music_on_hold|digits)$/) { + } elsif ($group_name =~ /^(music_on_hold|digits|custom_announcements)$/) { @services = (@pbx, "appserver"); } elsif ($group_name =~ /^(malicious_call_identification|voucher_recharge|play_balance|conference|calling_card)$/) { @services = ("appserver"); diff --git a/lib/NGCP/Panel/Utils/Sounds.pm b/lib/NGCP/Panel/Utils/Sounds.pm index f1d9728ed8..d9f4bced6e 100644 --- a/lib/NGCP/Panel/Utils/Sounds.pm +++ b/lib/NGCP/Panel/Utils/Sounds.pm @@ -126,10 +126,8 @@ sub get_handles_rs { if($set_rs->contract_id) { $handles_rs = $handles_rs->search({ - 'groups.name' => { '-in' => [qw/pbx music_on_hold digits/] } + 'groups.name' => { '-in' => [qw/pbx music_on_hold digits custom_announcements/] } }); - } else { - #$handles_rs = $handles_rs->search({ 'groups.name' => { '!=' => 'pbx' } }); } unless($c->config->{features}->{cloudpbx}) {