|
1 | 1 | import { db } from '@sim/db' |
2 | | -import { chat, workflow } from '@sim/db/schema' |
| 2 | +import { chat } from '@sim/db/schema' |
3 | 3 | import { createLogger } from '@sim/logger' |
4 | 4 | import { generateId } from '@sim/utils/id' |
5 | 5 | import { and, eq, isNull } from 'drizzle-orm' |
@@ -156,44 +156,6 @@ export const POST = withRouteHandler( |
156 | 156 |
|
157 | 157 | if (!deployment.isActive) { |
158 | 158 | logger.warn(`[${requestId}] Chat is not active: ${identifier}`) |
159 | | - |
160 | | - const [workflowRecord] = await db |
161 | | - .select({ workspaceId: workflow.workspaceId }) |
162 | | - .from(workflow) |
163 | | - .where(and(eq(workflow.id, deployment.workflowId), isNull(workflow.archivedAt))) |
164 | | - .limit(1) |
165 | | - |
166 | | - const workspaceId = workflowRecord?.workspaceId |
167 | | - if (!workspaceId) { |
168 | | - logger.warn( |
169 | | - `[${requestId}] Cannot log: workflow ${deployment.workflowId} has no workspace` |
170 | | - ) |
171 | | - return createErrorResponse('This chat is currently unavailable', 403) |
172 | | - } |
173 | | - |
174 | | - const executionId = generateId() |
175 | | - const loggingSession = new LoggingSession( |
176 | | - deployment.workflowId, |
177 | | - executionId, |
178 | | - 'chat', |
179 | | - requestId |
180 | | - ) |
181 | | - |
182 | | - await loggingSession.safeStart({ |
183 | | - userId: deployment.userId, |
184 | | - workspaceId, |
185 | | - variables: {}, |
186 | | - }) |
187 | | - |
188 | | - await loggingSession.safeCompleteWithError({ |
189 | | - error: { |
190 | | - message: 'This chat is currently unavailable. The chat has been disabled.', |
191 | | - stackTrace: undefined, |
192 | | - }, |
193 | | - traceSpans: [], |
194 | | - skipCost: true, |
195 | | - }) |
196 | | - |
197 | 159 | return createErrorResponse('This chat is currently unavailable', 403) |
198 | 160 | } |
199 | 161 |
|
|
0 commit comments