Fix variable replacement format in send-notification
The replaceVariables function was only supporting {{key}} format but
the email templates use {key} format (single braces). Updated to support
both formats for compatibility.
Changes:
- Added support for {key} format in addition to {{key}}
- Ensures all template variables are properly replaced
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -223,7 +223,9 @@ async function sendViaMailgun(payload: EmailPayload, apiKey: string, domain: str
|
|||||||
function replaceVariables(template: string, variables: Record<string, string>): string {
|
function replaceVariables(template: string, variables: Record<string, string>): string {
|
||||||
let result = template;
|
let result = template;
|
||||||
for (const [key, value] of Object.entries(variables)) {
|
for (const [key, value] of Object.entries(variables)) {
|
||||||
|
// Support both {key} and {{key}} formats
|
||||||
result = result.replace(new RegExp(`{{${key}}}`, 'g'), value);
|
result = result.replace(new RegExp(`{{${key}}}`, 'g'), value);
|
||||||
|
result = result.replace(new RegExp(`{${key}}`, 'g'), value);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user