From 5471f9115b898369ddb5a842df378ea506e17231 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Tue, 10 Jun 2014 16:30:02 +0200 Subject: [PATCH] MT#7271 API: Explicitely set cf pref on update Make sure that if we have a mapping, that we also set or update the preference to the mapping id. --- lib/NGCP/Panel/Role/API/CallForwards.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/Panel/Role/API/CallForwards.pm b/lib/NGCP/Panel/Role/API/CallForwards.pm index fe46925024..b4b537c275 100644 --- a/lib/NGCP/Panel/Role/API/CallForwards.pm +++ b/lib/NGCP/Panel/Role/API/CallForwards.pm @@ -149,7 +149,6 @@ sub update_item { type => $type, }); $mapping->discard_changes; # get our row - $cf_preference->create({ value => $mapping->id }); } elsif ($mapping_count > 1) { $self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Not a simple cf. Multiple $type-s configured."); return; @@ -160,6 +159,12 @@ sub update_item { } try { + if($cf_preference->first) { + $cf_preference->first->update({ value => $mapping->id }); + } else { + $cf_preference->create({ value => $mapping->id }); + } + my $primary_nr_rs = $item->primary_number; my $number; if ($primary_nr_rs) {