From 3549cd005286b79dfe4844dd21f965cb706498a1 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Thu, 23 Apr 2026 18:08:48 +0200 Subject: [PATCH] MT#64972 /api/customers email_template auto assign change * if an email template id is explicitly provided as "null", it will be assigned as "null". * remove email templates auto creation (copy from raw) for resellers if they do not have the specific one assigned to them. that proved to work contraversal as if a customer doesn't have an email template assigned to the reseller, and does not want to change their business logic (by explicitly providing "null") during POST /api/customers for those templates, the auto creation for reseller prevents it and causes complications, as well as it's not the intended role for /api/customers to automatically affect reseller configuration in such a way. Change-Id: Ie8cf0bffdd397279260a9601367f4457634ed5c8 (cherry picked from commit e956227ab0163e8f8479c6ea4bf39907b370c376) (cherry picked from commit c75eecde827579cb137cb9ea203671e53c6a3bf3) --- lib/NGCP/Panel/Controller/API/Customers.pm | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/Customers.pm b/lib/NGCP/Panel/Controller/API/Customers.pm index 2f5de0a174..7bf443e32b 100644 --- a/lib/NGCP/Panel/Controller/API/Customers.pm +++ b/lib/NGCP/Panel/Controller/API/Customers.pm @@ -293,6 +293,8 @@ sub POST :Allow { . "' that is assigned to Customer's Contact '$resource->{contact_id}'"); return; } + } elsif (exists $resource->{$field}) { + next; } else { next unless $t_def_name; @@ -301,22 +303,7 @@ sub POST :Allow { 'me.reseller_id' => $custcontact->reseller_id, })->first; - unless ($template) { - my $raw_def_template = $c->model('DB')->resultset($t_table)->search({ - 'me.name' => $t_def_name, - 'me.reseller_id' => undef - })->first; - - unless ($raw_def_template) { - $self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Cannot find basic default template '$t_def_name'"); - return; - } - - my $copy_template = { $raw_def_template->get_inflated_columns }; - delete $copy_template->{id}; - $copy_template->{reseller_id} = $custcontact->reseller_id; - $template = $c->model('DB')->resultset('email_templates')->create($copy_template); - } + next unless $template; $resource->{$field} = $template->id; }