From 9a439f70bc0de86040d3aedafc09c186643e2563 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 23:07:28 +0530 Subject: [PATCH] feat: recieve userId from socket --- .../src/workflow-management/classes/Generator.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index 0516703b..6d29b5fd 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -126,10 +126,12 @@ export class WorkflowGenerator { * @private */ private registerEventHandlers = (socket: Socket) => { - socket.on('save', async (fileName: string) => { - logger.log('debug', `Saving workflow ${fileName}`); - await this.saveNewWorkflow(fileName) - }); + socket.on('save', (data) => { + console.log('Received data:', data); + const { fileName, userId } = data; + logger.log('debug', `Saving workflow ${fileName} for user ID ${userId}`); + this.saveNewWorkflow(fileName, userId); + }); socket.on('new-recording', () => this.workflowRecord = { workflow: [], }); @@ -477,7 +479,7 @@ export class WorkflowGenerator { * @param fileName The name of the file. * @returns {Promise} */ - public saveNewWorkflow = async (fileName: string) => { + public saveNewWorkflow = async (fileName: string, userId: number) => { const recording = this.optimizeWorkflow(this.workflowRecord); try { this.recordingMeta = { @@ -489,6 +491,7 @@ export class WorkflowGenerator { params: this.getParams() || [], } const robot = await Robot.create({ + userId, recording_meta: this.recordingMeta, recording: recording, }); @@ -497,7 +500,7 @@ export class WorkflowGenerator { } catch (e) { const { message } = e as Error; - logger.log('warn', `Cannot save the file to the local file system`) + logger.log('warn', `Cannot save the file to the local file system ${e}`) } this.socket.emit('fileSaved'); }