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

View File

@ -309,6 +309,7 @@
'failedToFetchRenderedPosts': __('Failed to fetch rendered posts'),
'shortcodesWindowTitle': __('Select a shortcode'),
'unsubscribeLinkMissing': __('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.'),
'newsletterIsEmpty': __('Poet, please add prose to your masterpiece before you send it to your followers.'),
'emailAlreadySent': __('This email has already been sent. It can be edited, but not sent again. Duplicate this email if you want to send it again.'),
'automatedLatestContentMissing': _x('Please add an “Automatic Latest Content” widget to the email from the right sidebar.', '(Please reuse the current translation used for the string “Automatic Latest Content”) This Error message is displayed when a user tries to send a “Post Notification” email without any “Automatic Latest Content” widget inside'),
'newsletterPreviewEmailMissing': __('Enter an email address to send the preview newsletter to.'),