-
Notifications
You must be signed in to change notification settings - Fork 13.8k
feat(outbound): Apps engine bridge #36390
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
Merged
Merged
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
5aeb938
feat: adds new endpoints to interact with outbound providers
lucas-a-pelegrino 2cebc59
refactor: moves outbound endpoints to correct place
lucas-a-pelegrino c89c5db
refactor: adds more minor improvements to listOutboundPRoviders logic
lucas-a-pelegrino cc5126f
tests: adds unit testing for OutboundMessageProviderService
lucas-a-pelegrino 3d2d04a
chore: adds a minor improvement on OutboundMessageProviderService
lucas-a-pelegrino 0aa24b4
fix
KevLehman a565e9b
chore: adds minor improvements to typing to ensure reusability across…
lucas-a-pelegrino 056d740
Update apps/meteor/ee/app/livechat-enterprise/server/api/lib/outbound.ts
KevLehman fb5dff0
Update apps/meteor/ee/app/livechat-enterprise/server/api/lib/outbound.ts
KevLehman 95a0c4d
app engine outbound 1
KevLehman fa57364
oops
KevLehman 50d036e
oops
KevLehman a52cc5c
manager, provider & mod
KevLehman d388e38
dupe types
KevLehman 8cd5a76
ban types
KevLehman 7ce26fa
lint
KevLehman 79e6ee0
more proxies
KevLehman 188bc88
ts
KevLehman 2c8cb6b
lint
KevLehman fa458c7
the last?
KevLehman 8133210
test & proxies
KevLehman ec6e01c
types
KevLehman 75095da
lint
KevLehman 44f0a65
try
KevLehman 63a051b
registration working
KevLehman 17d918a
getprovidermetadata
KevLehman 48b6050
sendmessage
KevLehman 4a32452
fixes
KevLehman 3016524
polish
KevLehman 29d352d
iblock
KevLehman 3389db8
Merge branch 'develop' into feat/app-bridge-outbound
d-gubert f2d3281
Merge branch 'develop' into feat/app-bridge-outbound
d-gubert 26036bf
Merge branch 'develop' into feat/app-bridge-outbound
d-gubert 6532450
Merge branch 'develop' into feat/app-bridge-outbound
d-gubert 0c13013
async unregister
sampaiodiego 69e9b15
Merge branch 'develop' into feat/app-bridge-outbound
sampaiodiego f135a13
unregister async
sampaiodiego 37eb1f8
Merge branch 'feat/app-bridge-outbound' of github.com:RocketChat/Rock…
sampaiodiego d9210ec
Merge branch 'develop' into feat/app-bridge-outbound
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
apps/meteor/app/apps/server/bridges/outboundCommunication.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { IAppServerOrchestrator } from '@rocket.chat/apps'; | ||
| import type { | ||
| IOutboundEmailMessageProvider, | ||
| IOutboundMessageProviders, | ||
| IOutboundPhoneMessageProvider, | ||
| } from '@rocket.chat/apps-engine/definition/outboundComunication'; | ||
| import { OutboundMessageBridge } from '@rocket.chat/apps-engine/server/bridges'; | ||
|
|
||
| import { getOutboundService } from '../../../livechat/server/lib/outboundcommunication'; | ||
|
|
||
| export class OutboundCommunicationBridge extends OutboundMessageBridge { | ||
| constructor(private readonly orch: IAppServerOrchestrator) { | ||
| super(); | ||
| } | ||
|
|
||
| protected async registerPhoneProvider(provider: IOutboundPhoneMessageProvider, appId: string): Promise<void> { | ||
| try { | ||
| this.orch.debugLog(`App ${appId} is registering a phone outbound provider.`); | ||
| getOutboundService().outboundMessageProvider.registerPhoneProvider(provider); | ||
| } catch (err) { | ||
| this.orch.getRocketChatLogger().error({ appId, err, msg: 'Failed to register phone provider' }); | ||
| throw new Error('error-registering-provider'); | ||
| } | ||
| } | ||
|
|
||
| protected async registerEmailProvider(provider: IOutboundEmailMessageProvider, appId: string): Promise<void> { | ||
| try { | ||
| this.orch.debugLog(`App ${appId} is registering an email outbound provider.`); | ||
| getOutboundService().outboundMessageProvider.registerEmailProvider(provider); | ||
| } catch (err) { | ||
| this.orch.getRocketChatLogger().error({ appId, err, msg: 'Failed to register email provider' }); | ||
| throw new Error('error-registering-provider'); | ||
| } | ||
| } | ||
|
|
||
| protected async unRegisterProvider(provider: IOutboundMessageProviders, appId: string): Promise<void> { | ||
| try { | ||
| this.orch.debugLog(`App ${appId} is unregistering an outbound provider.`); | ||
| getOutboundService().outboundMessageProvider.unregisterProvider(appId, provider.type); | ||
| } catch (err) { | ||
| this.orch.getRocketChatLogger().error({ appId, err, msg: 'Failed to unregister provider' }); | ||
| throw new Error('error-unregistering-provider'); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import type { IOutboundMessageProviderService } from '@rocket.chat/core-typings'; | ||
| import { makeFunction } from '@rocket.chat/patch-injection'; | ||
|
|
||
| export const getOutboundService = makeFunction((): IOutboundMessageProviderService => { | ||
| throw new Error('error-no-license'); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/apps-engine/deno-runtime/handlers/outboundcomms-handler.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { JsonRpcError, Defined } from 'jsonrpc-lite'; | ||
| import type { IOutboundMessageProviders } from '@rocket.chat/apps-engine/definition/outboundCommunication/IOutboundCommsProvider.ts'; | ||
|
|
||
| import { AppObjectRegistry } from '../AppObjectRegistry.ts'; | ||
| import { AppAccessorsInstance } from '../lib/accessors/mod.ts'; | ||
| import { Logger } from '../lib/logger.ts'; | ||
|
|
||
| export default async function outboundMessageHandler(call: string, params: unknown): Promise<JsonRpcError | Defined> { | ||
| const [, providerName, methodName] = call.split(':'); | ||
| const provider = AppObjectRegistry.get<IOutboundMessageProviders>(`outboundCommunication:${providerName}`); | ||
| if (!provider) { | ||
| return new JsonRpcError('error-invalid-provider', -32000); | ||
| } | ||
| const method = provider[methodName as keyof IOutboundMessageProviders]; | ||
| const logger = AppObjectRegistry.get<Logger>('logger'); | ||
| const args = (params as Array<unknown>) ?? []; | ||
|
|
||
| try { | ||
| logger?.debug(`Executing ${methodName} on outbound communication provider...`); | ||
|
|
||
| // deno-lint-ignore ban-types | ||
| return await (method as Function).apply(provider, [ | ||
| ...args, | ||
| AppAccessorsInstance.getReader(), | ||
| AppAccessorsInstance.getModifier(), | ||
| AppAccessorsInstance.getHttp(), | ||
| AppAccessorsInstance.getPersistence(), | ||
| ]); | ||
| } catch (e) { | ||
| return new JsonRpcError(e.message, -32000); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/apps-engine/src/definition/accessors/IOutboundCommunicationProviderExtend.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import type { IOutboundEmailMessageProvider, IOutboundPhoneMessageProvider } from '../outboundComunication'; | ||
|
|
||
| export interface IOutboundCommunicationProviderExtend { | ||
| registerPhoneProvider(provider: IOutboundPhoneMessageProvider): Promise<void>; | ||
| registerEmailProvider(provider: IOutboundEmailMessageProvider): Promise<void>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.