2
0

🚸 (sendEmail) Allow html parsing for body with a single variable

This commit is contained in:
Baptiste Arnaud
2023-04-18 08:45:10 +02:00
parent 7c2ce2fc41
commit de432ecaf7
3 changed files with 12 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import { defaultFrom, defaultTransportOptions } from './constants'
import { ExecuteIntegrationResponse } from '@/features/chat/types'
import { saveErrorLog } from '@/features/logs/saveErrorLog'
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
import { findUniqueVariableValue } from '../../../variables/findUniqueVariableValue'
export const executeSendEmailBlock = async (
{ 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 {
await sendEmail({
typebotId: typebot.id,
@ -46,7 +51,7 @@ export const executeSendEmailBlock = async (
credentialsId: options.credentialsId,
recipients: options.recipients.map(parseVariables(variables)),
subject: parseVariables(variables)(options.subject ?? ''),
body: parseVariables(variables, { escapeHtml: true })(options.body ?? ''),
body,
cc: (options.cc ?? []).map(parseVariables(variables)),
bcc: (options.bcc ?? []).map(parseVariables(variables)),
replyTo: options.replyTo

View File

@ -14,7 +14,7 @@ import {
SessionState,
SetVariableBlock,
} 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 { getNextGroup } from './getNextGroup'
import { validateEmail } from '@/features/blocks/inputs/email/validateEmail'
@ -46,7 +46,7 @@ export const continueBotFlow =
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(
byId(block.options.variableId)
)

View File

@ -130,7 +130,10 @@ const sendAlertIfLimitReached = async (
const { totalChatsUsed, totalStorageUsed } = await getUsage(workspace.id)
const chatsLimit = getChatsLimit(workspace)
const storageLimit = getStorageLimit(workspace)
if (totalChatsUsed >= chatsLimit || totalStorageUsed >= storageLimit) {
if (
(chatsLimit > 0 && totalChatsUsed >= chatsLimit) ||
(storageLimit > 0 && totalStorageUsed >= storageLimit)
) {
events.push(
...workspace.members
.filter((member) => member.role !== WorkspaceRole.GUEST)