Skip to content

Commit

Permalink
fix(worker): Skip template rendering for Echo Workflow steps
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont committed Apr 5, 2024
1 parent 6001cd2 commit e38be43
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ export class SendMessageChat extends SendMessageBase {
let content = '';

try {
content = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template.content as string,
data: this.getCompilePayload(command.compileContext),
})
);
if (!command.chimeraData) {
content = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template.content as string,
data: this.getCompilePayload(command.compileContext),
})
);
}
} catch (e) {
await this.sendErrorHandlebars(command.job, e.message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,27 @@ export class SendMessageInApp extends SendMessageBase {
}

try {
const compiled = await this.compileInAppTemplate.execute(
CompileInAppTemplateCommand.create({
organizationId: command.organizationId,
environmentId: command.environmentId,
payload: this.getCompilePayload(command.compileContext),
content: step.template.content as string,
cta: step.template.cta,
userId: command.userId,
}),
this.initiateTranslations.bind(this)
);
content = compiled.content;
if (!command.chimeraData) {
const compiled = await this.compileInAppTemplate.execute(
CompileInAppTemplateCommand.create({
organizationId: command.organizationId,
environmentId: command.environmentId,
payload: this.getCompilePayload(command.compileContext),
content: step.template.content as string,
cta: step.template.cta,
userId: command.userId,
}),
this.initiateTranslations.bind(this)
);
content = compiled.content;

if (step.template.cta?.data?.url) {
step.template.cta.data.url = compiled.url;
}
if (step.template.cta?.data?.url) {
step.template.cta.data.url = compiled.url;
}

if (step.template.cta?.action?.buttons) {
step.template.cta.action.buttons = compiled.ctaButtons;
if (step.template.cta?.action?.buttons) {
step.template.cta.action.buttons = compiled.ctaButtons;
}
}
} catch (e) {
await this.sendErrorHandlebars(command.job, e.message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,21 @@ export class SendMessagePush extends SendMessageBase {
let title = '';

try {
content = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template?.content as string,
data,
})
);
if (!command.chimeraData) {
content = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template?.content as string,
data,
})
);

title = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template?.title as string,
data,
})
);
title = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template?.title as string,
data,
})
);
}
} catch (e) {
await this.sendErrorHandlebars(command.job, e.message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ export class SendMessageSms extends SendMessageBase {
let content: string | null = '';

try {
content = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template.content as string,
data: this.getCompilePayload(command.compileContext),
})
);
if (!command.chimeraData) {
content = await this.compileTemplate.execute(
CompileTemplateCommand.create({
template: step.template.content as string,
data: this.getCompilePayload(command.compileContext),
})
);
}
} catch (e) {
await this.sendErrorHandlebars(command.job, e.message);

Expand Down

0 comments on commit e38be43

Please sign in to comment.