-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: senderName and subject override for email providers (#4903)
* fix: sendername and subject override for email providers * fix: add sendername in return of compile email * fix: name mistake in sendgrid * fix: add sendername in plunk and netcore * fix: netcore and plunk test
- Loading branch information
1 parent
4e2c8a2
commit 63f7fe8
Showing
20 changed files
with
47 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,8 +158,10 @@ export class SendMessageEmail extends SendMessageBase { | |
let html; | ||
let subject = step?.template?.subject || ''; | ||
let content; | ||
let senderName; | ||
|
||
const payload = { | ||
senderName: step.template.senderName, | ||
subject, | ||
preheader: step.template.preheader, | ||
content: step.template.content, | ||
|
@@ -203,7 +205,7 @@ export class SendMessageEmail extends SendMessageBase { | |
} | ||
|
||
try { | ||
({ html, content, subject } = await this.compileEmailTemplateUsecase.execute( | ||
({ html, content, subject, senderName } = await this.compileEmailTemplateUsecase.execute( | ||
CompileEmailTemplateCommand.create({ | ||
environmentId: command.environmentId, | ||
organizationId: command.organizationId, | ||
|
@@ -272,6 +274,7 @@ export class SendMessageEmail extends SendMessageBase { | |
html, | ||
from: integration?.credentials.from || '[email protected]', | ||
attachments, | ||
senderName, | ||
id: message._id, | ||
replyTo: replyToAddress, | ||
notificationDetails: { | ||
|
@@ -292,13 +295,7 @@ export class SendMessageEmail extends SendMessageBase { | |
} | ||
|
||
if (email && integration) { | ||
await this.sendMessage( | ||
integration, | ||
mailData, | ||
message, | ||
command, | ||
overrides?.senderName || step.template.senderName | ||
); | ||
await this.sendMessage(integration, mailData, message, command); | ||
|
||
return; | ||
} | ||
|
@@ -433,11 +430,10 @@ export class SendMessageEmail extends SendMessageBase { | |
integration: IntegrationEntity, | ||
mailData: IEmailOptions, | ||
message: MessageEntity, | ||
command: SendMessageCommand, | ||
senderName?: string | ||
command: SendMessageCommand | ||
) { | ||
const mailFactory = new MailFactory(); | ||
const mailHandler = mailFactory.getHandler(this.buildFactoryIntegration(integration, senderName), mailData.from); | ||
const mailHandler = mailFactory.getHandler(this.buildFactoryIntegration(integration), mailData.from); | ||
|
||
try { | ||
const result = await mailHandler.send(mailData); | ||
|
@@ -547,7 +543,6 @@ export class SendMessageEmail extends SendMessageBase { | |
...integration, | ||
credentials: { | ||
...integration.credentials, | ||
senderName: senderName && senderName.length > 0 ? senderName : integration.credentials.senderName, | ||
}, | ||
providerId: integration.providerId, | ||
}; | ||
|
@@ -570,6 +565,8 @@ export const createMailData = (options: IEmailOptions, overrides: Record<string, | |
cc: overrides?.cc || [], | ||
bcc: overrides?.bcc || [], | ||
...ipPoolName, | ||
senderName: overrides?.senderName || options.senderName, | ||
subject: overrides?.subject || options.subject, | ||
customData: overrides?.customData || {}, | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ export class SESEmailProvider implements IEmailProvider { | |
text, | ||
to, | ||
from, | ||
senderName, | ||
subject, | ||
attachments, | ||
cc, | ||
|
@@ -50,7 +51,7 @@ export class SESEmailProvider implements IEmailProvider { | |
attachments, | ||
from: { | ||
address: from, | ||
name: this.config.senderName, | ||
name: senderName, | ||
}, | ||
cc, | ||
bcc, | ||
|
@@ -68,9 +69,11 @@ export class SESEmailProvider implements IEmailProvider { | |
cc, | ||
bcc, | ||
replyTo, | ||
senderName, | ||
}: IEmailOptions): Promise<ISendMessageSuccessResponse> { | ||
const info = await this.sendMail({ | ||
from: from || this.config.from, | ||
senderName: senderName || this.config.senderName, | ||
to: to, | ||
subject: subject, | ||
html: html, | ||
|
@@ -162,6 +165,7 @@ export class SESEmailProvider implements IEmailProvider { | |
bcc: [], | ||
cc: [], | ||
replyTo: '[email protected]', | ||
senderName: 'Novu Support', | ||
}); | ||
|
||
return { | ||
|
63f7fe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://dev.widget.novu.co as production
🚀 Deployed on https://6565de47053c7c6c6b679d3d--dev-widget-novu.netlify.app