🐛 Fixed link to posts on audio cards in emails

refs https://ghost.slack.com/archives/CTH5NDJMS/p1675356984043299

The url property doesn't exists on post, this was copied from the old MEGA flow that serialized the model first.
This commit is contained in:
Simon Backx 2023-02-02 18:12:46 +01:00
parent 509affb1f7
commit 0f08f39a1b
2 changed files with 12 additions and 8 deletions

View File

@ -176,14 +176,15 @@ class EmailRenderer {
}
renderPostBaseHtml(post) {
const postUrl = this.#getPostUrl(post);
let html;
if (post.get('lexical')) {
html = this.#renderers.lexical.render(
post.get('lexical'), {target: 'email', postUrl: post.url}
post.get('lexical'), {target: 'email', postUrl}
);
} else {
html = this.#renderers.mobiledoc.render(
JSON.parse(post.get('mobiledoc')), {target: 'email', postUrl: post.url}
JSON.parse(post.get('mobiledoc')), {target: 'email', postUrl}
);
}
return html;

View File

@ -260,12 +260,14 @@ describe('Email renderer', function () {
return '<p> Mobiledoc Test</p>';
}
}
},
getPostUrl: () => {
return 'http://example.com/post-id';
}
});
it('returns correct empty segment for post', function () {
let post = {
url: '',
get: (key) => {
if (key === 'lexical') {
return '{}';
@ -276,7 +278,6 @@ describe('Email renderer', function () {
response.should.eql([null]);
post = {
url: '',
get: (key) => {
if (key === 'mobiledoc') {
return '{}';
@ -295,11 +296,13 @@ describe('Email renderer', function () {
return '<p> Lexical Test <!--members-only--> members only section</p>';
}
}
},
getPostUrl: () => {
return 'http://example.com/post-id';
}
});
let post = {
url: '',
get: (key) => {
if (key === 'lexical') {
return '{}';
@ -318,11 +321,13 @@ describe('Email renderer', function () {
return '<html> <div> Lexical Test </div> <div data-gh-segment="status:-free"> members only section</div> </html>';
}
}
},
getPostUrl: () => {
return 'http://example.com/post-id';
}
});
let post = {
url: '',
get: (key) => {
if (key === 'lexical') {
return '{}';
@ -407,7 +412,6 @@ describe('Email renderer', function () {
beforeEach(function () {
basePost = {
url: '',
lexical: '{}',
visibility: 'public',
title: 'Test Post',
@ -693,7 +697,6 @@ describe('Email renderer', function () {
it('removes data-gh-segment and renders paywall', async function () {
renderedPost = '<div> Lexical Test </div> <div data-gh-segment="status:-free"> members only section</div> some text for both <!--members-only--> finishing part only for members';
let post = {
url: '',
related: () => {
return null;
},