Skip to content

Commit

Permalink
fix: add custom header support for resend, brevo and sendgrid (#5343)
Browse files Browse the repository at this point in the history
Co-authored-by: Dima Grossman <[email protected]>
  • Loading branch information
jainpawan21 and scopsy committed Apr 29, 2024
1 parent f806e83 commit b1920de
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 1 deletion.
Expand Up @@ -537,6 +537,7 @@ export const createMailData = (options: IEmailOptions, overrides: Record<string,
senderName: overrides?.senderName || options.senderName,
subject: overrides?.subject || options.subject,
customData: overrides?.customData || {},
headers: overrides?.headers || {},
};
};

Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/types/events/index.ts
Expand Up @@ -36,6 +36,7 @@ export interface IEmailOptions {
notificationDetails?: any;
ipPoolName?: string;
customData?: Record<string, any>;
headers?: Record<string, string>;
senderName?: string;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/node/README.md
Expand Up @@ -541,7 +541,10 @@ await novu.events.trigger("workflowIdentifier", {
// customData will work only for sendgrid
customData: {
"customKey": "customValue"
}
},
headers: {
'X-Novu-Custom-Header': 'Novu-Custom-Header-Value',
},
}
},
// actorId is subscriberId of actor
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/lib/events/events.interface.ts
Expand Up @@ -37,6 +37,7 @@ export interface IEmailOverrides extends IIntegrationOverride {
bcc?: string[];
senderName?: string;
customData?: Record<string, any>;
headers?: Record<string, string>;
}

export type ITriggerTenant = string | ITenantDefine;
Expand Down
3 changes: 3 additions & 0 deletions packages/node/src/lib/events/events.spec.ts
Expand Up @@ -114,6 +114,9 @@ describe('test use of novus node package - Events', () => {
name: 'Fourth Child',
},
},
headers: {
'X-Novu-Custom-Header': 'test-data',
},
},
},
payload: {
Expand Down
1 change: 1 addition & 0 deletions packages/stateless/src/lib/provider/provider.interface.ts
Expand Up @@ -24,6 +24,7 @@ export interface IEmailOptions {
notificationDetails?: any;
ipPoolName?: string;
customData?: Record<string, any>;
headers?: Record<string, string>;
senderName?: string;
}

Expand Down
1 change: 1 addition & 0 deletions providers/resend/src/lib/resend.provider.ts
Expand Up @@ -42,6 +42,7 @@ export class ResendEmailProvider implements IEmailProvider {
content: attachment.file,
})),
bcc: options.bcc,
headers: options.headers,
});

if (response.error) {
Expand Down
1 change: 1 addition & 0 deletions providers/sendgrid/src/lib/sendgrid.provider.ts
Expand Up @@ -128,6 +128,7 @@ export class SendgridEmailProvider implements IEmailProvider {
},
],
templateId: templateId,
headers: options.headers,
};

if (options.replyTo) {
Expand Down
1 change: 1 addition & 0 deletions providers/sendinblue/src/lib/brevo.provider.ts
Expand Up @@ -47,6 +47,7 @@ export class BrevoEmailProvider implements IEmailProvider {
name: attachment?.name,
content: attachment?.file.toString('base64'),
}));
email.headers = options.headers;

if (options.cc?.length) {
email.cc = options.cc?.map((ccItem) => ({ email: ccItem }));
Expand Down

0 comments on commit b1920de

Please sign in to comment.