Prevent sending email without body

[MAILPOET-2366]
This commit is contained in:
Pavel Dohnal
2019-09-19 14:47:44 +02:00
committed by Jack Kitterhing
parent 7bb0603230
commit e56a654b2b
2 changed files with 7 additions and 0 deletions

View File

@ -249,13 +249,19 @@ Module.SaveView = Marionette.View.extend({
validateNewsletter: function (jsonObject) {
var body = '';
var newsletter = App.getNewsletter();
var content;
if (!App._contentContainer.isValid()) {
this.showValidationError(App._contentContainer.validationError);
return;
}
if (jsonObject && jsonObject.body && jsonObject.body.content) {
content = jsonObject.body.content;
body = JSON.stringify(jsonObject.body.content);
if (!content.blocks || !Array.isArray(content.blocks) || (content.blocks.length === 0)) {
this.showValidationError(MailPoet.I18n.t('newsletterIsEmpty'));
return;
}
}
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent')
&& body.indexOf('[link:subscription_unsubscribe_url]') < 0