Simplify newsletter body data repair

[MAILPOET-3430]
This commit is contained in:
Jan Lysý
2021-02-24 15:41:56 +01:00
committed by Veljko V
parent 78717509c8
commit 878e3eb28f
4 changed files with 18 additions and 20 deletions

View File

@ -61,8 +61,10 @@ class NewsletterTemplates extends APIEndpoint {
public function save($data = []) {
ignore_user_abort(true);
$body = $this->apiDataSanitizer->sanitizeBody(json_decode($data['body'], true));
$data['body'] = json_encode($body);
if (!empty($data['body'])) {
$body = $this->apiDataSanitizer->sanitizeBody(json_decode($data['body'], true));
$data['body'] = json_encode($body);
}
try {
$template = $this->newsletterTemplatesRepository->createOrUpdate($data);
if (!empty($data['categories']) && $data['categories'] === NewsletterTemplatesRepository::RECENTLY_SENT_CATEGORIES) {