From b7d5345db735826df7e3ca43e4fb1660ab5072a0 Mon Sep 17 00:00:00 2001 From: Rafael Tapia Date: Tue, 22 Oct 2024 17:13:44 -0300 Subject: [PATCH] chore: deprecate `from` --- apps/meteor/app/apps/server/bridges/email.ts | 9 ++++++++- packages/apps-engine/src/definition/email/IEmail.ts | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/meteor/app/apps/server/bridges/email.ts b/apps/meteor/app/apps/server/bridges/email.ts index 4c9cb9a93ed6..6d75a4504483 100644 --- a/apps/meteor/app/apps/server/bridges/email.ts +++ b/apps/meteor/app/apps/server/bridges/email.ts @@ -3,6 +3,7 @@ import type { IEmail } from '@rocket.chat/apps-engine/definition/email'; import { EmailBridge } from '@rocket.chat/apps-engine/server/bridges'; import * as Mailer from '../../../mailer/server/api'; +import { settings } from '../../../settings/server'; export class AppEmailBridge extends EmailBridge { constructor(private readonly orch: IAppServerOrchestrator) { @@ -10,7 +11,13 @@ export class AppEmailBridge extends EmailBridge { } protected async sendEmail(email: IEmail, appId: string): Promise { + let { from } = email; + if (!from) { + this.orch.debugLog(`The app ${appId} didn't provide a from address, using the default one.`); + from = String(settings.get('From_Email')); + } + this.orch.debugLog(`The app ${appId} is sending an email.`); - await Mailer.send(email); + await Mailer.send({ ...email, from }); } } diff --git a/packages/apps-engine/src/definition/email/IEmail.ts b/packages/apps-engine/src/definition/email/IEmail.ts index ca81b23e5bcc..27acdc085971 100644 --- a/packages/apps-engine/src/definition/email/IEmail.ts +++ b/packages/apps-engine/src/definition/email/IEmail.ts @@ -1,6 +1,9 @@ export interface IEmail { to: string | string[]; - from: string; + /** + * @deprecated this will be inferred from the settings + */ + from?: string; replyTo?: string; subject: string; html?: string;