Skip to content

Commit 7e73017

Browse files
committed
fix: priority fix for send email
1 parent bddb937 commit 7e73017

File tree

6 files changed

+17
-8
lines changed

6 files changed

+17
-8
lines changed

apps/backend/src/services/auth/auth.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export class AuthService {
2121
private _emailService: EmailService
2222
) {}
2323
async canRegister(provider: string) {
24-
if (process.env.DISABLE_REGISTRATION !== 'true' || provider === Provider.GENERIC) {
24+
if (
25+
process.env.DISABLE_REGISTRATION !== 'true' ||
26+
provider === Provider.GENERIC
27+
) {
2528
return true;
2629
}
2730

@@ -69,7 +72,8 @@ export class AuthService {
6972
await this._emailService.sendEmail(
7073
body.email,
7174
'Activate your account',
72-
`Click <a href="${process.env.FRONTEND_URL}/auth/activate/${obj.jwt}">here</a> to activate your account`
75+
`Click <a href="${process.env.FRONTEND_URL}/auth/activate/${obj.jwt}">here</a> to activate your account`,
76+
'top'
7377
);
7478
return obj;
7579
}

apps/orchestrator/src/activities/email.activity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export class EmailActivity {
1717
}
1818

1919
@ActivityMethod()
20-
async sendEmailAsync(to: string, subject: string, html: string, replyTo?: string) {
21-
return await this._emailService.sendEmail(to, subject, html, replyTo);
20+
async sendEmailAsync(to: string, subject: string, html: string, sendTo: 'top' | 'bottom', replyTo?: string) {
21+
return await this._emailService.sendEmail(to, subject, html, sendTo, replyTo);
2222
}
2323

2424
@ActivityMethod()

apps/orchestrator/src/signals/send.email.signal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export type SendEmail = {
55
subject: string;
66
html: string;
77
replyTo?: string;
8+
addTo: 'top' | 'bottom';
89
};
910
export const sendEmailSignal = defineSignal<[SendEmail]>('sendEmail');

apps/orchestrator/src/workflows/send.email.workflow.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export async function sendEmailWorkflow({
2828
// Handle incoming email signals
2929
setHandler(sendEmailSignal, (addEmail: SendEmail) => {
3030
if (addEmail.to && addEmail.subject) {
31-
queue.push(addEmail);
31+
if (addEmail.addTo === 'top') {
32+
queue.unshift(addEmail);
33+
} else {
34+
queue.push(addEmail);
35+
}
3236
}
3337
});
3438

libraries/nestjs-libraries/src/database/prisma/notifications/notification.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class NotificationService {
101101
}
102102

103103
async sendEmail(to: string, subject: string, html: string, replyTo?: string) {
104-
await this._emailService.sendEmail(to, subject, html, replyTo);
104+
await this._emailService.sendEmail(to, subject, html, 'bottom', replyTo);
105105
}
106106

107107
hasEmailProvider() {

libraries/nestjs-libraries/src/services/email.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ export class EmailService {
3333
}
3434
}
3535

36-
async sendEmail(to: string, subject: string, html: string, replyTo?: string) {
36+
async sendEmail(to: string, subject: string, html: string, sendTo: 'top' | 'bottom', replyTo?: string) {
3737
return this._temporalService.client
3838
.getRawClient()
3939
?.workflow.signalWithStart('sendEmailWorkflow', {
4040
taskQueue: 'main',
4141
workflowId: 'send_email',
4242
signal: 'sendEmail',
4343
args: [{ queue: [] }],
44-
signalArgs: [{ to, subject, html, replyTo }],
44+
signalArgs: [{ to, subject, html, replyTo, sendTo }],
4545
workflowIdConflictPolicy: 'USE_EXISTING',
4646
});
4747
}

0 commit comments

Comments
 (0)