🚸 (sendEmail) Allow html parsing for body with a single variable
This commit is contained in:
@ -20,6 +20,7 @@ import { defaultFrom, defaultTransportOptions } from './constants'
|
|||||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||||
|
import { findUniqueVariableValue } from '../../../variables/findUniqueVariableValue'
|
||||||
|
|
||||||
export const executeSendEmailBlock = async (
|
export const executeSendEmailBlock = async (
|
||||||
{ result, typebot }: SessionState,
|
{ result, typebot }: SessionState,
|
||||||
@ -39,6 +40,10 @@ export const executeSendEmailBlock = async (
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const body =
|
||||||
|
findUniqueVariableValue(variables)(options.body)?.toString() ??
|
||||||
|
parseVariables(variables, { escapeHtml: true })(options.body ?? '')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendEmail({
|
await sendEmail({
|
||||||
typebotId: typebot.id,
|
typebotId: typebot.id,
|
||||||
@ -46,7 +51,7 @@ export const executeSendEmailBlock = async (
|
|||||||
credentialsId: options.credentialsId,
|
credentialsId: options.credentialsId,
|
||||||
recipients: options.recipients.map(parseVariables(variables)),
|
recipients: options.recipients.map(parseVariables(variables)),
|
||||||
subject: parseVariables(variables)(options.subject ?? ''),
|
subject: parseVariables(variables)(options.subject ?? ''),
|
||||||
body: parseVariables(variables, { escapeHtml: true })(options.body ?? ''),
|
body,
|
||||||
cc: (options.cc ?? []).map(parseVariables(variables)),
|
cc: (options.cc ?? []).map(parseVariables(variables)),
|
||||||
bcc: (options.bcc ?? []).map(parseVariables(variables)),
|
bcc: (options.bcc ?? []).map(parseVariables(variables)),
|
||||||
replyTo: options.replyTo
|
replyTo: options.replyTo
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
SessionState,
|
SessionState,
|
||||||
SetVariableBlock,
|
SetVariableBlock,
|
||||||
} from '@typebot.io/schemas'
|
} from '@typebot.io/schemas'
|
||||||
import { isInputBlock, isNotDefined, byId, isDefined } from '@typebot.io/lib'
|
import { isInputBlock, isNotDefined, byId } from '@typebot.io/lib'
|
||||||
import { executeGroup } from './executeGroup'
|
import { executeGroup } from './executeGroup'
|
||||||
import { getNextGroup } from './getNextGroup'
|
import { getNextGroup } from './getNextGroup'
|
||||||
import { validateEmail } from '@/features/blocks/inputs/email/validateEmail'
|
import { validateEmail } from '@/features/blocks/inputs/email/validateEmail'
|
||||||
@ -46,7 +46,7 @@ export const continueBotFlow =
|
|||||||
message: 'Current block not found',
|
message: 'Current block not found',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (block.type === LogicBlockType.SET_VARIABLE && isDefined(reply)) {
|
if (block.type === LogicBlockType.SET_VARIABLE) {
|
||||||
const existingVariable = state.typebot.variables.find(
|
const existingVariable = state.typebot.variables.find(
|
||||||
byId(block.options.variableId)
|
byId(block.options.variableId)
|
||||||
)
|
)
|
||||||
|
@ -130,7 +130,10 @@ const sendAlertIfLimitReached = async (
|
|||||||
const { totalChatsUsed, totalStorageUsed } = await getUsage(workspace.id)
|
const { totalChatsUsed, totalStorageUsed } = await getUsage(workspace.id)
|
||||||
const chatsLimit = getChatsLimit(workspace)
|
const chatsLimit = getChatsLimit(workspace)
|
||||||
const storageLimit = getStorageLimit(workspace)
|
const storageLimit = getStorageLimit(workspace)
|
||||||
if (totalChatsUsed >= chatsLimit || totalStorageUsed >= storageLimit) {
|
if (
|
||||||
|
(chatsLimit > 0 && totalChatsUsed >= chatsLimit) ||
|
||||||
|
(storageLimit > 0 && totalStorageUsed >= storageLimit)
|
||||||
|
) {
|
||||||
events.push(
|
events.push(
|
||||||
...workspace.members
|
...workspace.members
|
||||||
.filter((member) => member.role !== WorkspaceRole.GUEST)
|
.filter((member) => member.role !== WorkspaceRole.GUEST)
|
||||||
|
Reference in New Issue
Block a user