Skip to content

Commit

Permalink
chore: deprecate from field from Email Bridge (#33713)
Browse files Browse the repository at this point in the history
Co-authored-by: Douglas Gubert <1810309+d-gubert@users.noreply.github.com>
  • Loading branch information
tapiarafael and d-gubert authored Oct 23, 2024
1 parent b59bedc commit 82767d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/forty-gorillas-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@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
9 changes: 8 additions & 1 deletion apps/meteor/app/apps/server/bridges/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ 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) {
super();
}

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.`);
await Mailer.send(email);
await Mailer.send({ ...email, from });
}
}
5 changes: 4 additions & 1 deletion packages/apps-engine/src/definition/email/IEmail.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 82767d8

Please sign in to comment.