Skip to content

Commit

Permalink
chore: change the bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustrb committed Aug 13, 2024
1 parent 333901b commit 50099d4
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions apps/meteor/app/apps/server/bridges/email.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import { EmailBridge } from '@rocket.chat/apps-engine/server/bridges/EmailBridge';

Check failure on line 2 in apps/meteor/app/apps/server/bridges/email.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Unable to resolve path to module '@rocket.chat/apps-engine/server/bridges/EmailBridge'
import type { IEmail } from '@rocket.chat/apps-engine/server/definitions/email';

import { i18n } from '../../../../server/lib/i18n';
import * as Mailer from '../../../mailer/server/api';
import { settings } from '../../../settings/server';

export class AppEmailBridge extends EmailBridge {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

protected async sendOtpCodeThroughSMTP(email: string, code: string, language: string, appId: string): Promise<void> {
protected async sendEmail(email: IEmail, appId: string): Promise<void> {
this.orch.debugLog(`The app: ${appId} is requesting an OTP code to be sent to: ${email}`);
await this.send2FAEmail(email, code, language);
}

private async send2FAEmail(email: string, code: string, language: string): Promise<void> {
const t = (s: string): string => i18n.t(s, { lng: language || 'en' });

await Mailer.send({
to: email,
from: settings.get('From_Email'),
subject: 'Authentication code',
replyTo: undefined,
data: {
code: code.replace(/^(\d{3})/, '$1-'),
},
headers: undefined,
text: `
${t('Here_is_your_authentication_code')}
__code__
${t('Do_not_provide_this_code_to_anyone')}
${t('If_you_didnt_try_to_login_in_your_account_please_ignore_this_email')}
`,
html: `
<p>${t('Here_is_your_authentication_code')}</p>
<p style="font-size: 30px;">
<b>__code__</b>
</p>
<p>${t('Do_not_provide_this_code_to_anyone')}</p>
<p>${t('If_you_didnt_try_to_login_in_your_account_please_ignore_this_email')}</p>
`,
});
await Mailer.send(email);
}
}

0 comments on commit 50099d4

Please sign in to comment.