Skip to content
Snippets Groups Projects
Unverified Commit 82767d8f authored by Rafael Tapia's avatar Rafael Tapia Committed by GitHub
Browse files

chore: deprecate `from` field from Email Bridge (#33713)

parent b59bedc5
No related branches found
No related tags found
No related merge requests found
---
"@rocket.chat/meteor": patch
"@rocket.chat/apps-engine": patch
---
Deprecated the `from` field in the apps email bridge and made it optional, using the server's settings when the field is omitted
...@@ -3,6 +3,7 @@ import type { IEmail } from '@rocket.chat/apps-engine/definition/email'; ...@@ -3,6 +3,7 @@ import type { IEmail } from '@rocket.chat/apps-engine/definition/email';
import { EmailBridge } from '@rocket.chat/apps-engine/server/bridges'; import { EmailBridge } from '@rocket.chat/apps-engine/server/bridges';
import * as Mailer from '../../../mailer/server/api'; import * as Mailer from '../../../mailer/server/api';
import { settings } from '../../../settings/server';
export class AppEmailBridge extends EmailBridge { export class AppEmailBridge extends EmailBridge {
constructor(private readonly orch: IAppServerOrchestrator) { constructor(private readonly orch: IAppServerOrchestrator) {
...@@ -10,7 +11,13 @@ export class AppEmailBridge extends EmailBridge { ...@@ -10,7 +11,13 @@ export class AppEmailBridge extends EmailBridge {
} }
protected async sendEmail(email: IEmail, appId: string): Promise<void> { protected async sendEmail(email: IEmail, appId: string): Promise<void> {
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.`); this.orch.debugLog(`The app ${appId} is sending an email.`);
await Mailer.send(email); await Mailer.send({ ...email, from });
} }
} }
export interface IEmail { export interface IEmail {
to: string | string[]; to: string | string[];
from: string; /**
* @deprecated this will be inferred from the settings
*/
from?: string;
replyTo?: string; replyTo?: string;
subject: string; subject: string;
html?: string; html?: string;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment