Skip to content

Commit

Permalink
fix: Fixed WPP.contact.queryExists function for WhatsApp WEB >= 2.2241.6
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 25, 2022
1 parent 9676e60 commit 4005f36
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 87 deletions.
33 changes: 2 additions & 31 deletions src/contact/functions/queryExists.ts
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 1 addition & 5 deletions src/whatsapp/functions/sendQueryExists.ts
Expand Up @@ -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
);
50 changes: 0 additions & 50 deletions src/whatsapp/misc/Wap.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/whatsapp/misc/index.ts
Expand Up @@ -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';

0 comments on commit 4005f36

Please sign in to comment.