Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate from field from Email Bridge #33713

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));
}
Comment on lines +14 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have gone with the good old email.from validation and assignment here, but you do you 😂


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
Loading