mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:01:08 +02:00
fix(notify-client): don't send undefined emailOptions
Only include emailOptions object when from or replyTo is provided, preventing validation errors when these optional fields are not set. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
971e269fbd
commit
7ffee52408
1 changed files with 24 additions and 12 deletions
|
|
@ -36,7 +36,7 @@ export class NotifyClient {
|
|||
* Send an email notification
|
||||
*/
|
||||
async sendEmail(options: SendEmailOptions): Promise<NotificationResponse> {
|
||||
return this.send({
|
||||
const payload: Record<string, unknown> = {
|
||||
channel: 'email',
|
||||
appId: this.appId,
|
||||
recipient: options.to,
|
||||
|
|
@ -44,13 +44,19 @@ export class NotifyClient {
|
|||
subject: options.subject,
|
||||
body: options.body,
|
||||
data: options.data,
|
||||
emailOptions: {
|
||||
from: options.from,
|
||||
replyTo: options.replyTo,
|
||||
},
|
||||
priority: options.priority,
|
||||
externalId: options.externalId,
|
||||
});
|
||||
};
|
||||
|
||||
// Only include emailOptions if from or replyTo is provided
|
||||
if (options.from || options.replyTo) {
|
||||
payload.emailOptions = {
|
||||
...(options.from && { from: options.from }),
|
||||
...(options.replyTo && { replyTo: options.replyTo }),
|
||||
};
|
||||
}
|
||||
|
||||
return this.send(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,7 +123,7 @@ export class NotifyClient {
|
|||
* Schedule an email notification
|
||||
*/
|
||||
async scheduleEmail(options: SendEmailOptions & ScheduleOptions): Promise<NotificationResponse> {
|
||||
return this.schedule({
|
||||
const payload: Record<string, unknown> = {
|
||||
channel: 'email',
|
||||
appId: this.appId,
|
||||
recipient: options.to,
|
||||
|
|
@ -125,17 +131,23 @@ export class NotifyClient {
|
|||
subject: options.subject,
|
||||
body: options.body,
|
||||
data: options.data,
|
||||
emailOptions: {
|
||||
from: options.from,
|
||||
replyTo: options.replyTo,
|
||||
},
|
||||
priority: options.priority,
|
||||
externalId: options.externalId,
|
||||
scheduledFor:
|
||||
options.scheduledFor instanceof Date
|
||||
? options.scheduledFor.toISOString()
|
||||
: options.scheduledFor,
|
||||
});
|
||||
};
|
||||
|
||||
// Only include emailOptions if from or replyTo is provided
|
||||
if (options.from || options.replyTo) {
|
||||
payload.emailOptions = {
|
||||
...(options.from && { from: options.from }),
|
||||
...(options.replyTo && { replyTo: options.replyTo }),
|
||||
};
|
||||
}
|
||||
|
||||
return this.schedule(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue