Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/src/sponsorDocs/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1676,9 +1676,10 @@ export function renderSponsorEmailDraft(options: {
}

if (options.template === 'podcast-episode-brief') {
const firstName = options.recipientName?.trim().split(/\s+/)[0];
const guestName = options.recipientName?.trim() || options.sponsorName?.trim() || '';
const firstName = guestName.split(/\s+/)[0];
const body = [
firstName ? `Hi ${firstName},` : 'Hi <NAME>,',
firstName ? `Hi ${firstName},` : 'Hi there,',
'',
`Here is the episode brief with the structure and questions for ${pubDate}:`,
'',
Expand Down
8 changes: 8 additions & 0 deletions backend/tests/podcast-doc-email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ describe('podcast doc emails', () => {
assert.doesNotMatch(body, /Hi team|staff-only|Internal/);
});

it('falls back to the guest name on the doc, then to a neutral greeting, never a placeholder', () => {
const fromDoc = renderSponsorEmailDraft({ ...base, template: 'podcast-episode-brief' }).body;
assert.match(fromDoc, /^Hi Sofiia,/);
const neutral = renderSponsorEmailDraft({ ...base, sponsorName: null, template: 'podcast-episode-brief' }).body;
assert.match(neutral, /^Hi there,/);
assert.doesNotMatch(neutral, /<NAME>/);
});

for (const template of ['podcast-guest-research', 'podcast-run-sheet'] as const) {
it(`keeps staff wording for ${template}`, () => {
const { body } = renderSponsorEmailDraft({ ...base, template });
Expand Down