From cfcaa7584b40043317a0feba5e29666c59172e82 Mon Sep 17 00:00:00 2001 From: Richard Fontein <32132657+rifont@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:32:16 +0100 Subject: [PATCH] fix(worker): Remove custom Slack provider handling in send-message-chat (#6328) --- .../send-message/send-message-chat.usecase.ts | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/apps/worker/src/app/workflow/usecases/send-message/send-message-chat.usecase.ts b/apps/worker/src/app/workflow/usecases/send-message/send-message-chat.usecase.ts index 293421cdb43..2dfdb7089ff 100644 --- a/apps/worker/src/app/workflow/usecases/send-message/send-message-chat.usecase.ts +++ b/apps/worker/src/app/workflow/usecases/send-message/send-message-chat.usecase.ts @@ -31,7 +31,7 @@ import { ExecutionLogRoute, ExecutionLogRouteCommand, } from '@novu/application-generic'; -import { ExecuteOutput } from '@novu/framework'; +import { ChatOutput, ExecuteOutput } from '@novu/framework'; import { CreateLog } from '../../../shared/logs'; import { SendMessageCommand } from './send-message.command'; @@ -88,7 +88,8 @@ export class SendMessageChat extends SendMessageBase { step.template = template; } - let content = ''; + const bridgeOutput = command.bridgeData?.outputs as ChatOutput | undefined; + let content: string = bridgeOutput?.body || ''; try { if (!command.bridgeData) { @@ -392,7 +393,6 @@ export class SendMessageChat extends SendMessageBase { throw new PlatformException(`Chat handler for provider ${integration.providerId} is not found`); } - const bridgeContent = this.getOverrideContent(command.bridgeData, integration); const overrides = { ...(command.overrides[integration?.channel] || {}), ...(command.overrides[integration?.providerId] || {}), @@ -405,7 +405,7 @@ export class SendMessageChat extends SendMessageBase { customData: overrides, webhookUrl: chatWebhookUrl, channel: channelSpecification, - ...(bridgeContent?.content ? bridgeContent : { content }), + content, }); await this.executionLogRoute.execute( @@ -445,21 +445,4 @@ export class SendMessageChat extends SendMessageBase { ); } } - - private getOverrideContent( - bridgeData: ExecuteOutput | undefined | null, - integration: IntegrationEntity - ): Record & { content: string } { - const bridgeProviderOverride = this.getBridgeOverride(bridgeData?.providers, integration); - - // TODO: make this generic to handle all providers. - let bridgeContent: Record & { content: string }; - if (bridgeProviderOverride) { - bridgeContent = { content: bridgeProviderOverride.text as string, blocks: bridgeProviderOverride.blocks }; - } else { - bridgeContent = { content: bridgeData?.outputs.body as string }; - } - - return bridgeContent; - } }