From a65041ffcd251eb3e8a75d0dcabcf817450a6cb9 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Mon, 12 Aug 2024 10:56:16 +0700 Subject: [PATCH] [core] DELETE /api/sessions/{session}/ --- src/api/sessions.controller.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/api/sessions.controller.ts b/src/api/sessions.controller.ts index 9a7df0cb..18e62788 100644 --- a/src/api/sessions.controller.ts +++ b/src/api/sessions.controller.ts @@ -96,6 +96,23 @@ class SessionsController { return await this.manager.getSessionInfo(name); } + @Delete(':session/') + @SessionApiParam + @ApiOperation({ + summary: 'Delete the session', + description: + 'Delete the session with the given name. Stop and logout as well. Idempotent operation.', + }) + @UsePipes(new WAHAValidationPipe()) + async delete(@Param('session') name: string): Promise { + if (this.manager.isRunning(name)) { + await this.manager.stop(name, true); + await sleep(2000); + } + await this.manager.logout(name); + await this.manager.delete(name); + } + @Post(':session/start') @SessionApiParam @ApiOperation({ @@ -130,23 +147,6 @@ class SessionsController { await this.manager.stop(name, false); return await this.manager.getSessionInfo(name); } - - @Delete(':session/') - @SessionApiParam - @ApiOperation({ - summary: 'Delete the session', - description: - 'Delete the session with the given name. Stop and logout if required. Idempotent operation.', - }) - @UsePipes(new WAHAValidationPipe()) - async delete(@Param('session') name: string): Promise { - if (this.manager.isRunning(name)) { - await this.stop(name); - await sleep(2000); - } - await this.manager.logout(name); - await this.manager.delete(name); - } } @ApiSecurity('api_key')