added id to whatsbot session types

This commit is contained in:
canove
2020-09-20 18:03:57 -03:00
parent cb3ba09252
commit 9bd4c30d3c
2 changed files with 6 additions and 7 deletions

View File

@@ -1,5 +0,0 @@
declare namespace WAWebJS {
export interface ClientInfo {
meuId: number;
}
}

View File

@@ -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<void> => {
console.log("starting");
@@ -84,7 +88,7 @@ export const initWbot = async (whatsapp: Whatsapp): Promise<void> => {
}
};
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) {