mikelustosa / Projeto-TInject

Projeto TInject
246 stars 132 forks source link

checkNumberStatus don't work for Betta #33

Closed sergey-chechaev closed 2 years ago

sergey-chechaev commented 2 years ago

Function checkNumberStatus do not work for Multi-Device Beta version of WhatsApp

{ id: "WapQuery", conditions: (module) => (module.default && module.default.queryExist) ? module.default : null }

window.WAPI.checkNumberStatus = function(id, done) {
    window.Store.WapQuery.queryExist(id).then((result) => {
        if (done !== undefined) {
            if (result.jid === undefined) throw 404;
            done(window.WAPI._serializeNumberStatusObj(result));
        }
    }).catch((e) => {
        if (done !== undefined) {
            done(window.WAPI._serializeNumberStatusObj({
                status: e,
                jid: id
            }));
        }
    });

    return true;
};

image

mikelustosa commented 2 years ago

Function dont exist in beta version.

antoniocmoura commented 2 years ago

this works for me:

{ id: 'checkNumberBeta', conditions: (module) => module.default && typeof module.default.toString === 'function' && module.default.toString().includes('Should not reach queryExists MD') ? module.default : null },

window.WAPI.isBeta = function () {
    if (
        !window.localStorage.getItem('WASecretBundle') &&
        !window.localStorage.getItem('WAToken1') &&
        !window.localStorage.getItem('WAToken2')
    ) {
        return true;
    }
    return false;
}

window.WAPI.checkNumberStatus = function (id, done) {
    if (window.WAPI.isBeta) {
        return await window.Store.checkNumberBeta(id)
            .then((result) => {                
                if (!!result && typeof result === 'object') {
                    // number exists
                } else {
                    // number not exists
                }
            })
            .catch((err) => {
                // number not exists
            });
    } else {
        window.Store.WapQuery.queryExist(id).then((result) => {
            if (done !== undefined) {
                if (result.jid === undefined) throw 404;
                done(window.WAPI._serializeNumberStatusObj(result));
            }
        }).catch((e) => {
            if (done !== undefined) {
                done(window.WAPI._serializeNumberStatusObj({
                    status: e,
                    jid: id
                }));
            }
        });
        return true;
    }
};
mikelustosa commented 2 years ago

Fix in js.abr version 1.1.0.0