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
3 changes: 2 additions & 1 deletion apps/web/utils/ai/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const draft: ActionFunction<{
to?: string | null;
cc?: string | null;
bcc?: string | null;
}> = async ({ client, email, args, executedRule }) => {
}> = async ({ client, email, args, userEmail, executedRule }) => {
const draftArgs = {
to: args.to ?? undefined,
subject: args.subject ?? undefined,
Expand All @@ -119,6 +119,7 @@ const draft: ActionFunction<{
attachments: email.attachments,
},
draftArgs,
userEmail,
executedRule,
);
return { draftId: result.draftId };
Expand Down
5 changes: 3 additions & 2 deletions apps/web/utils/email/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,13 @@ export class GmailProvider implements EmailProvider {
async draftEmail(
email: ParsedMessage,
args: { to?: string; subject?: string; content: string },
userEmail: string,
executedRule?: { id: string; threadId: string; emailAccountId: string },
): Promise<{ draftId: string }> {
if (executedRule) {
// Run draft creation and previous draft deletion in parallel
const [result] = await Promise.all([
draftEmail(this.client, email, args),
draftEmail(this.client, email, args, userEmail),
handlePreviousDraftDeletion({
client: this,
executedRule,
Expand All @@ -292,7 +293,7 @@ export class GmailProvider implements EmailProvider {
]);
return { draftId: result.data.id || "" };
} else {
const result = await draftEmail(this.client, email, args);
const result = await draftEmail(this.client, email, args, userEmail);
return { draftId: result.data.id || "" };
}
}
Expand Down
5 changes: 3 additions & 2 deletions apps/web/utils/email/microsoft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,13 @@ export class OutlookProvider implements EmailProvider {
async draftEmail(
email: ParsedMessage,
args: { to?: string; subject?: string; content: string },
userEmail: string,
executedRule?: { id: string; threadId: string; emailAccountId: string },
): Promise<{ draftId: string }> {
if (executedRule) {
// Run draft creation and previous draft deletion in parallel
const [result] = await Promise.all([
draftEmail(this.client, email, args),
draftEmail(this.client, email, args, userEmail),
handlePreviousDraftDeletion({
client: this,
executedRule,
Expand All @@ -297,7 +298,7 @@ export class OutlookProvider implements EmailProvider {
]);
return { draftId: result.id || "" };
} else {
const result = await draftEmail(this.client, email, args);
const result = await draftEmail(this.client, email, args, userEmail);
return { draftId: result.id || "" };
}
}
Expand Down
Loading
Loading