Skip to content

Commit

Permalink
feat: email bridge (#33160)
Browse files Browse the repository at this point in the history
  • Loading branch information
tapiarafael authored Sep 2, 2024
1 parent 037128c commit 8338807
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-mayflies-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

Implemented sending email via apps
6 changes: 6 additions & 0 deletions apps/meteor/app/apps/server/bridges/bridges.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AppApisBridge } from './api';
import { AppCloudBridge } from './cloud';
import { AppCommandsBridge } from './commands';
import { AppDetailChangesBridge } from './details';
import { AppEmailBridge } from './email';
import { AppEnvironmentalVariableBridge } from './environmental';
import { AppHttpBridge } from './http';
import { AppInternalBridge } from './internal';
Expand Down Expand Up @@ -53,6 +54,7 @@ export class RealAppBridges extends AppBridges {
this._moderationBridge = new AppModerationBridge(orch);
this._threadBridge = new AppThreadBridge(orch);
this._roleBridge = new AppRoleBridge(orch);
this._emailBridge = new AppEmailBridge(orch);
}

getCommandBridge() {
Expand Down Expand Up @@ -150,4 +152,8 @@ export class RealAppBridges extends AppBridges {
getRoleBridge() {
return this._roleBridge;
}

getEmailBridge() {
return this._emailBridge;
}
}
16 changes: 16 additions & 0 deletions apps/meteor/app/apps/server/bridges/email.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
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';

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

protected async sendEmail(email: IEmail, appId: string): Promise<void> {
this.orch.debugLog(`The app ${appId} is sending an email.`);
await Mailer.send(email);
}
}
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "Rocket.Chat",
"license": "MIT",
"dependencies": {
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/core-services": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.25",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
"@rocket.chat/agenda": "workspace:^",
"@rocket.chat/api-client": "workspace:^",
"@rocket.chat/apps": "workspace:^",
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/base64": "workspace:^",
"@rocket.chat/cas-validate": "workspace:^",
"@rocket.chat/core-services": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/ddp-streamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"author": "Rocket.Chat",
"dependencies": {
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/core-services": "workspace:^",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/emitter": "~0.31.25",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/presence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@babel/core": "~7.22.20",
"@babel/preset-env": "~7.22.20",
"@babel/preset-typescript": "~7.22.15",
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/rest-typings": "workspace:^",
"@types/node": "^14.18.63",
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/model-typings": "workspace:^"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"extends": "../../package.json"
},
"dependencies": {
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/icons": "~0.38.0",
"@rocket.chat/message-parser": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/icons": "~0.38.0",
"@rocket.chat/message-parser": "workspace:^",
"@rocket.chat/ui-kit": "workspace:~"
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage-ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@babel/preset-env": "~7.22.20",
"@babel/preset-react": "~7.22.15",
"@babel/preset-typescript": "~7.22.15",
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/eslint-config": "workspace:^",
"@rocket.chat/fuselage": "^0.57.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"/dist"
],
"dependencies": {
"@rocket.chat/apps-engine": "1.45.0-alpha.866",
"@rocket.chat/apps-engine": "1.45.0-alpha.868",
"@rocket.chat/core-typings": "workspace:^",
"@rocket.chat/message-parser": "workspace:^",
"@rocket.chat/ui-kit": "workspace:~",
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8483,9 +8483,9 @@ __metadata:
languageName: unknown
linkType: soft

"@rocket.chat/apps-engine@npm:1.45.0-alpha.866":
version: 1.45.0-alpha.866
resolution: "@rocket.chat/apps-engine@npm:1.45.0-alpha.866"
"@rocket.chat/apps-engine@npm:1.45.0-alpha.868":
version: 1.45.0-alpha.868
resolution: "@rocket.chat/apps-engine@npm:1.45.0-alpha.868"
dependencies:
"@msgpack/msgpack": 3.0.0-beta2
adm-zip: ^0.5.9
Expand All @@ -8501,15 +8501,15 @@ __metadata:
uuid: ~8.3.2
peerDependencies:
"@rocket.chat/ui-kit": "*"
checksum: 04abb4f712fcca206c6791322b52e2a3d97f3db06f606cd1f58fdda4e63d2123d7004bb445ad7582c52808c3ec4433d465d8855e24f3ab2f8457dafa6b017c5b
checksum: 3ac41e3de76be67e856e4bca888f113360628e510f9d4c66d70ed71d84f25bda6ca6659ead6c7a87d21c117c47bfa090b4508cce66e8630d2e935d3ed3158835
languageName: node
linkType: hard

"@rocket.chat/apps@workspace:^, @rocket.chat/apps@workspace:packages/apps":
version: 0.0.0-use.local
resolution: "@rocket.chat/apps@workspace:packages/apps"
dependencies:
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/model-typings": "workspace:^"
eslint: ~8.45.0
Expand Down Expand Up @@ -8582,7 +8582,7 @@ __metadata:
"@babel/core": ~7.22.20
"@babel/preset-env": ~7.22.20
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ~0.38.0
Expand All @@ -8609,7 +8609,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/core-typings@workspace:packages/core-typings"
dependencies:
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/icons": ~0.38.0
"@rocket.chat/message-parser": "workspace:^"
Expand Down Expand Up @@ -8681,7 +8681,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/ddp-streamer@workspace:ee/apps/ddp-streamer"
dependencies:
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/ddp-client": "workspace:~"
Expand Down Expand Up @@ -8879,7 +8879,7 @@ __metadata:
"@babel/preset-env": ~7.22.20
"@babel/preset-react": ~7.22.15
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
"@rocket.chat/fuselage": ^0.57.0
Expand Down Expand Up @@ -9329,7 +9329,7 @@ __metadata:
"@rocket.chat/agenda": "workspace:^"
"@rocket.chat/api-client": "workspace:^"
"@rocket.chat/apps": "workspace:^"
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/base64": "workspace:^"
"@rocket.chat/cas-validate": "workspace:^"
"@rocket.chat/core-services": "workspace:^"
Expand Down Expand Up @@ -9952,7 +9952,7 @@ __metadata:
"@babel/core": ~7.22.20
"@babel/preset-env": ~7.22.20
"@babel/preset-typescript": ~7.22.15
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:^"
Expand Down Expand Up @@ -10066,7 +10066,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@rocket.chat/rest-typings@workspace:packages/rest-typings"
dependencies:
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/eslint-config": "workspace:~"
"@rocket.chat/message-parser": "workspace:^"
Expand Down Expand Up @@ -36701,7 +36701,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "rocketchat-services@workspace:apps/meteor/ee/server/services"
dependencies:
"@rocket.chat/apps-engine": 1.45.0-alpha.866
"@rocket.chat/apps-engine": 1.45.0-alpha.868
"@rocket.chat/core-services": "workspace:^"
"@rocket.chat/core-typings": "workspace:^"
"@rocket.chat/emitter": ~0.31.25
Expand Down

0 comments on commit 8338807

Please sign in to comment.