From 9bd4c30d3ce6ee89db4d145173403da241805931 Mon Sep 17 00:00:00 2001 From: canove Date: Sun, 20 Sep 2020 18:03:57 -0300 Subject: [PATCH] added id to whatsbot session types --- backend/src/@types/WAWebJS.d.ts | 5 ----- backend/src/libs/wbot.ts | 8 ++++++-- 2 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 backend/src/@types/WAWebJS.d.ts diff --git a/backend/src/@types/WAWebJS.d.ts b/backend/src/@types/WAWebJS.d.ts deleted file mode 100644 index 0d17ab2..0000000 --- a/backend/src/@types/WAWebJS.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace WAWebJS { - export interface ClientInfo { - meuId: number; - } -} diff --git a/backend/src/libs/wbot.ts b/backend/src/libs/wbot.ts index 4cbf5dd..68ef54b 100644 --- a/backend/src/libs/wbot.ts +++ b/backend/src/libs/wbot.ts @@ -3,7 +3,11 @@ import { Client } from "whatsapp-web.js"; import { getIO } from "./socket"; import Whatsapp from "../models/Whatsapp"; -const sessions: Client[] = []; +interface Session extends Client { + id?: number; +} + +const sessions: Session[] = []; export const initWbot = async (whatsapp: Whatsapp): Promise => { console.log("starting"); @@ -84,7 +88,7 @@ export const initWbot = async (whatsapp: Whatsapp): Promise => { } }; -export const getWbot = (whatsappId: number): Client | null => { +export const getWbot = (whatsappId: number): Session | null => { const sessionIndex = sessions.findIndex(s => s.id === whatsappId); if (sessionIndex === -1) {