From 02dc26d4cd96099e48cf4e43579f0765923a2418 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Wed, 9 Nov 2022 16:49:11 +0100 Subject: [PATCH] MT#55618 /api/subscribers fix default contract_sound_set assignment * when a new subscriber is created via POST, if the associated customer has at least one default contract_sound_set, it is correctly assigned to the subscriber as the "contract_sound_set" preference. the logic is now inline with the UI behaviour Change-Id: Ifeb86faf6718648b29e6391bd16752766358ed0f (cherry picked from commit 826d3f1d9ff5b9de4d72838ce9f616f253cdb47f) --- lib/NGCP/Panel/Utils/Subscriber.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/NGCP/Panel/Utils/Subscriber.pm b/lib/NGCP/Panel/Utils/Subscriber.pm index 5cab5a6634..2f1f62dcf5 100644 --- a/lib/NGCP/Panel/Utils/Subscriber.pm +++ b/lib/NGCP/Panel/Utils/Subscriber.pm @@ -532,6 +532,16 @@ sub prepare_resource { $preferences->{ext_contract_id} = $customer->external_id; } + # find and assign default contract sound set (if exists) + if (!$item) { + my $default_contract_sound_set_row = $customer->voip_sound_sets->search( + { contract_default => 1 })->first; + + if ($default_contract_sound_set_row) { + $preferences->{contract_sound_set} = $default_contract_sound_set_row->id; + } + } + my $subscriber = $c->model('DB')->resultset('voip_subscribers')->find({ username => $resource->{username}, domain_id => $resource->{domain_id},