🐛 Use published typebot for result transcript instead of dev typebot

This commit is contained in:
Baptiste Arnaud 2025-09-17 14:15:43 +02:00
parent d8bb1f7c40
commit 33b36d76fc
No known key found for this signature in database

View File

@ -53,12 +53,15 @@ export const getResultTranscript = authenticatedProcedure
id: input.typebotId,
},
select: {
id: true,
version: true,
groups: true,
edges: true,
variables: true,
events: true,
publishedTypebot: {
select: {
version: true,
groups: true,
edges: true,
variables: true,
events: true,
},
},
workspace: {
select: {
isSuspended: true,
@ -79,14 +82,17 @@ export const getResultTranscript = authenticatedProcedure
},
});
if (!typebot || (await isReadTypebotForbidden(typebot, user)))
if (
!typebot?.publishedTypebot ||
(await isReadTypebotForbidden(typebot, user))
)
throw new TRPCError({ code: "NOT_FOUND", message: "Typebot not found" });
// Fetch result data
const result = await prisma.result.findUnique({
where: {
id: input.resultId,
typebotId: typebot.id,
typebotId: input.typebotId,
},
select: {
answers: {
@ -148,7 +154,10 @@ export const getResultTranscript = authenticatedProcedure
}));
const transcript = computeResultTranscript({
typebot: typebotInSessionStateSchema.parse(typebot),
typebot: typebotInSessionStateSchema.parse({
...typebot.publishedTypebot,
id: input.typebotId,
}),
answers,
setVariableHistory,
visitedEdges,