fix: priority fix for send email

This commit is contained in:
Nevo David 2026-01-07 09:54:45 +07:00
parent bddb937258
commit 7e73017d3f
6 changed files with 17 additions and 8 deletions

View File

@ -21,7 +21,10 @@ export class AuthService {
private _emailService: EmailService
) {}
async canRegister(provider: string) {
if (process.env.DISABLE_REGISTRATION !== 'true' || provider === Provider.GENERIC) {
if (
process.env.DISABLE_REGISTRATION !== 'true' ||
provider === Provider.GENERIC
) {
return true;
}
@ -69,7 +72,8 @@ export class AuthService {
await this._emailService.sendEmail(
body.email,
'Activate your account',
`Click <a href="${process.env.FRONTEND_URL}/auth/activate/${obj.jwt}">here</a> to activate your account`
`Click <a href="${process.env.FRONTEND_URL}/auth/activate/${obj.jwt}">here</a> to activate your account`,
'top'
);
return obj;
}

View File

@ -17,8 +17,8 @@ export class EmailActivity {
}
@ActivityMethod()
async sendEmailAsync(to: string, subject: string, html: string, replyTo?: string) {
return await this._emailService.sendEmail(to, subject, html, replyTo);
async sendEmailAsync(to: string, subject: string, html: string, sendTo: 'top' | 'bottom', replyTo?: string) {
return await this._emailService.sendEmail(to, subject, html, sendTo, replyTo);
}
@ActivityMethod()

View File

@ -5,5 +5,6 @@ export type SendEmail = {
subject: string;
html: string;
replyTo?: string;
addTo: 'top' | 'bottom';
};
export const sendEmailSignal = defineSignal<[SendEmail]>('sendEmail');

View File

@ -28,7 +28,11 @@ export async function sendEmailWorkflow({
// Handle incoming email signals
setHandler(sendEmailSignal, (addEmail: SendEmail) => {
if (addEmail.to && addEmail.subject) {
queue.push(addEmail);
if (addEmail.addTo === 'top') {
queue.unshift(addEmail);
} else {
queue.push(addEmail);
}
}
});

View File

@ -101,7 +101,7 @@ export class NotificationService {
}
async sendEmail(to: string, subject: string, html: string, replyTo?: string) {
await this._emailService.sendEmail(to, subject, html, replyTo);
await this._emailService.sendEmail(to, subject, html, 'bottom', replyTo);
}
hasEmailProvider() {

View File

@ -33,7 +33,7 @@ export class EmailService {
}
}
async sendEmail(to: string, subject: string, html: string, replyTo?: string) {
async sendEmail(to: string, subject: string, html: string, sendTo: 'top' | 'bottom', replyTo?: string) {
return this._temporalService.client
.getRawClient()
?.workflow.signalWithStart('sendEmailWorkflow', {
@ -41,7 +41,7 @@ export class EmailService {
workflowId: 'send_email',
signal: 'sendEmail',
args: [{ queue: [] }],
signalArgs: [{ to, subject, html, replyTo }],
signalArgs: [{ to, subject, html, replyTo, sendTo }],
workflowIdConflictPolicy: 'USE_EXISTING',
});
}