(chatflowId: string, workspaceId: string)
| 633 | } |
| 634 | |
| 635 | const setWebhookSecret = async (chatflowId: string, workspaceId: string): Promise<{ webhookSecret: string }> => { |
| 636 | try { |
| 637 | const appServer = getRunningExpressApp() |
| 638 | const repo = appServer.AppDataSource.getRepository(ChatFlow) |
| 639 | const chatflow = await repo.findOne({ where: { id: chatflowId, workspaceId } }) |
| 640 | if (!chatflow) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Chatflow ${chatflowId} not found`) |
| 641 | const plaintext = randomBytes(32).toString('hex') |
| 642 | chatflow.webhookSecret = await encryptCredentialData({ secret: plaintext }) |
| 643 | chatflow.webhookSecretConfigured = true |
| 644 | await repo.save(chatflow) |
| 645 | return { webhookSecret: plaintext } |
| 646 | } catch (error) { |
| 647 | if (error instanceof InternalFlowiseError) throw error |
| 648 | throw new InternalFlowiseError( |
| 649 | StatusCodes.INTERNAL_SERVER_ERROR, |
| 650 | `Error: chatflowsService.setWebhookSecret - ${getErrorMessage(error)}` |
| 651 | ) |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | const clearWebhookSecret = async (chatflowId: string, workspaceId: string): Promise<void> => { |
| 656 | try { |
nothing calls this directly
no test coverage detected