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
master
Kirill Solomko 1 week ago
parent e5d7232b63
commit e956227ab0

@ -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;
}

Loading…
Cancel
Save