(req: Request, res: Response, next: NextFunction)
| 188 | } |
| 189 | |
| 190 | const updateChatflow = async (req: Request, res: Response, next: NextFunction) => { |
| 191 | try { |
| 192 | if (typeof req.params === 'undefined' || !req.params.id) { |
| 193 | throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: chatflowsController.updateChatflow - id not provided!`) |
| 194 | } |
| 195 | const workspaceId = req.user?.activeWorkspaceId |
| 196 | if (!workspaceId) { |
| 197 | throw new InternalFlowiseError( |
| 198 | StatusCodes.NOT_FOUND, |
| 199 | `Error: chatflowsController.saveChatflow - workspace ${workspaceId} not found!` |
| 200 | ) |
| 201 | } |
| 202 | const chatflow = await chatflowsService.getChatflowById(req.params.id, workspaceId) |
| 203 | if (!chatflow) { |
| 204 | return res.status(404).send('Chatflow not found') |
| 205 | } |
| 206 | const orgId = req.user?.activeOrganizationId |
| 207 | if (!orgId) { |
| 208 | throw new InternalFlowiseError( |
| 209 | StatusCodes.NOT_FOUND, |
| 210 | `Error: chatflowsController.saveChatflow - organization ${orgId} not found!` |
| 211 | ) |
| 212 | } |
| 213 | const subscriptionId = req.user?.activeOrganizationSubscriptionId || '' |
| 214 | const body = req.body |
| 215 | const updateChatFlow = new ChatFlow() |
| 216 | Object.assign(updateChatFlow, stripProtectedFields(body)) |
| 217 | |
| 218 | updateChatFlow.id = chatflow.id |
| 219 | const rateLimiterManager = RateLimiterManager.getInstance() |
| 220 | await rateLimiterManager.updateRateLimiter(updateChatFlow) |
| 221 | |
| 222 | const apiResponse = await chatflowsService.updateChatflow(chatflow, updateChatFlow, orgId, workspaceId, subscriptionId) |
| 223 | return res.json(apiResponse) |
| 224 | } catch (error) { |
| 225 | next(error) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | const getSinglePublicChatflow = async (req: Request, res: Response, next: NextFunction) => { |
| 230 | let queryRunner: QueryRunner | undefined |
nothing calls this directly
no test coverage detected