diff --git a/core/server/services/mega/mega.js b/core/server/services/mega/mega.js index 9c64d86ba8..bd261ad06d 100644 --- a/core/server/services/mega/mega.js +++ b/core/server/services/mega/mega.js @@ -26,9 +26,9 @@ const getEmailData = async (postModel, members = []) => { members.forEach((member) => { emails.push(member.email); - // firstname is a computed property only used here for now + // first_name is a computed property only used here for now // TODO: move into model computed property or output serializer? - member.firstname = (member.name || '').split(' ')[0]; + member.first_name = (member.name || '').split(' ')[0]; // add static data to mailgun template variables const data = { diff --git a/core/server/services/mega/post-email-serializer.js b/core/server/services/mega/post-email-serializer.js index 7d8b492928..ec48902452 100644 --- a/core/server/services/mega/post-email-serializer.js +++ b/core/server/services/mega/post-email-serializer.js @@ -60,7 +60,7 @@ const _parseReplacements = (emailTmpl) => { const EMAIL_REPLACEMENT_REGEX = /%%(\{.*?\})%%/g; // the " is necessary here because `juice` will convert "->" for email compatibility const REPLACEMENT_STRING_REGEX = /\{(?\w*?)(?:,? *(?:"|")(?.*?)(?:"|"))?\}/; - const ALLOWED_REPLACEMENTS = ['subscriber_firstname']; + const ALLOWED_REPLACEMENTS = ['first_name']; const replacements = []; ['html', 'plaintext'].forEach((format) => { @@ -77,7 +77,7 @@ const _parseReplacements = (emailTmpl) => { format, id, match: replacementMatch, - memberProp: memberProp.replace('subscriber_', ''), + memberProp, fallback }); diff --git a/test/api-acceptance/admin/email_preview_spec.js b/test/api-acceptance/admin/email_preview_spec.js index ac473c713e..1e1d77a0a7 100644 --- a/test/api-acceptance/admin/email_preview_spec.js +++ b/test/api-acceptance/admin/email_preview_spec.js @@ -75,7 +75,7 @@ describe('Email Preview API', function () { id: ObjectId.generate(), title: 'Post with email-only card', slug: 'email-only-card', - mobiledoc: '{"version":"0.3.1","atoms":[],"cards":[["email",{"html":"

Hey {subscriber_firstname \\"there\\"} {unknown}

Welcome to your first Ghost email!

"}],["email",{"html":"

Another email card with a similar replacement, {subscriber_firstname, \\"see?\\"}

"}]],"markups":[],"sections":[[10,0],[1,"p",[[0,[],0,"This is the actual post content..."]]],[10,1],[1,"p",[]]]}', + mobiledoc: '{"version":"0.3.1","atoms":[],"cards":[["email",{"html":"

Hey {first_name \\"there\\"} {unknown}

Welcome to your first Ghost email!

"}],["email",{"html":"

Another email card with a similar replacement, {first_name, \\"see?\\"}

"}]],"markups":[],"sections":[[10,0],[1,"p",[[0,[],0,"This is the actual post content..."]]],[10,1],[1,"p",[]]]}', html: '

This is the actual post content...

', plaintext: 'This is the actual post content...', status: 'draft',