From 4005f36e3e5b14f6fa58cc496b7e49ec890adb90 Mon Sep 17 00:00:00 2001 From: Edgard Date: Mon, 24 Oct 2022 22:25:20 -0300 Subject: [PATCH] fix: Fixed WPP.contact.queryExists function for WhatsApp WEB >= 2.2241.6 --- src/contact/functions/queryExists.ts | 33 +-------------- src/whatsapp/functions/sendQueryExists.ts | 6 +-- src/whatsapp/misc/Wap.ts | 50 ----------------------- src/whatsapp/misc/index.ts | 1 - 4 files changed, 3 insertions(+), 87 deletions(-) delete mode 100644 src/whatsapp/misc/Wap.ts diff --git a/src/contact/functions/queryExists.ts b/src/contact/functions/queryExists.ts index 0ee60cf28b..f7e0960a75 100644 --- a/src/contact/functions/queryExists.ts +++ b/src/contact/functions/queryExists.ts @@ -15,8 +15,7 @@ */ import { assertWid } from '../../assert'; -import { isMultiDevice } from '../../conn'; -import { Wap, Wid } from '../../whatsapp'; +import { Wid } from '../../whatsapp'; import { sendQueryExists } from '../../whatsapp/functions'; export interface QueryExistsResult { @@ -63,35 +62,7 @@ export async function queryExists( return cache.get(id)!; } - let result: QueryExistsResult | null = null; - - if (!isMultiDevice()) { - const query = await Wap.queryExist(id); - if (query.status === 200) { - result = { - wid: query.jid, - biz: query.biz || false, - }; - - // @todo: Migrate condition to isDisappearingModeEnabled() - if (result) { - const disappearing = await Wap.queryDisappearingMode(wid).catch( - () => null - ); - - if (disappearing?.status === 200) { - result.disappearingMode = { - duration: disappearing.duration!, - settingTimestamp: disappearing.settingTimestamp!, - }; - } - } - } - } - - if (!result) { - result = await sendQueryExists(wid).catch(() => null); - } + const result = await sendQueryExists(wid).catch(() => null); cache.set(id, result); diff --git a/src/whatsapp/functions/sendQueryExists.ts b/src/whatsapp/functions/sendQueryExists.ts index 96acaa4487..ed45b80e8f 100644 --- a/src/whatsapp/functions/sendQueryExists.ts +++ b/src/whatsapp/functions/sendQueryExists.ts @@ -43,11 +43,7 @@ exportModule( { sendQueryExists: [ 'queryExists', // @whatsapp >= 2.2208.7 - 'default', ], }, - (m) => - m.default?.toString().includes('Should not reach queryExists MD') || - m.queryExists?.toString().includes('Should not reach queryExists MD') || // @whatsapp >= 2.2208.7 - (m.queryExists && m.queryPhoneExists) // @whatsapp >= 2.2211.2 + (m) => m.queryExists && m.queryPhoneExists // @whatsapp >= 2.2211.2 ); diff --git a/src/whatsapp/misc/Wap.ts b/src/whatsapp/misc/Wap.ts deleted file mode 100644 index ca0de67e54..0000000000 --- a/src/whatsapp/misc/Wap.ts +++ /dev/null @@ -1,50 +0,0 @@ -/*! - * Copyright 2021 WPPConnect Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { exportModule } from '../exportModule'; -import { Wid } from '.'; - -/** @whatsapp 86875 - * @whatsapp 56891 >= 2.2212.8 - * @whatsapp 656891 >= 2.2222.8 - */ -export declare class WapClass { - queryExist(contactId: string): Promise<{ - status: 200; - jid: Wid; - biz?: true; - }>; - queryDisappearingMode(contactId: Wid): Promise<{ - status: 200; - duration: number; - settingTimestamp: number; - }>; -} - -/** @whatsapp 86875 - * @whatsapp 56891 >= 2.2212.8 - * @whatsapp 656891 >= 2.2222.8 - */ -export declare const Wap: WapClass; - -exportModule( - exports, - { - WapClass: 'instance.constructor', - Wap: 'instance', - }, - (m) => m.instance?.queryExist -); diff --git a/src/whatsapp/misc/index.ts b/src/whatsapp/misc/index.ts index 013c0b88f7..038729a553 100644 --- a/src/whatsapp/misc/index.ts +++ b/src/whatsapp/misc/index.ts @@ -38,6 +38,5 @@ export * from './Socket'; export * from './Stream'; export * from './UserPrefs'; export * from './VCard'; -export * from './Wap'; export * from './Wid'; export * from './WidFactory';