Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

one bug fixed about group message #793

@xinkyo

Description

@xinkyo

when send group message, it takes 30 seconds to send, when I trace the code, the bug happend at mongoAuthState.js
const writeData = (data, id) => {
this fucntion when data is array, it is not writen, need to change to object.

const writeData = (data, id) => {
// console.log('write data array')
// console.log(data)
if (Array.isArray(data)) {
const obj = {};
data.forEach((value, index) => {
obj[index] = value;
});
data = obj;
}

    return collection.replaceOne(
        { _id: id },
        JSON.parse(JSON.stringify(data, BufferJSON.replacer)),
        { upsert: true }
    )
}

2nd part is :
const BufferJSON = {
replacer: (k, value) => {

here add type:buffer is not working, because it is changed to string before add type:buffer. don' know how to fix. in stead, in reviver ,I add the code to change base64 code to buffer.

else if ((k === 'seed' || k === 'public' || k === 'private') && typeof value === 'string') {
// Convert the base64 string back to a Buffer
return Buffer.from(value, 'base64');
}

@whiskeysockets/baileys/lib/Signal/libsignal.js
here when loadSenderKey, the key should be array, but mongoAuthState send the object, temporaly I change to array here to array.

loadSenderKey: async (keyId) => {

        const { [keyId]: key } = await keys.get('sender-key', [keyId]);
       
        if (key) {
            if(typeof key==='object'){
           
            let testkey4 = convertObjectToArray(key)
           let    record=new WASignalGroup_1.SenderKeyRecord(testkey4)
           return record;
                }else{
                    let    record=new WASignalGroup_1.SenderKeyRecord(key)
                      return record;
                }

          
        }
    },

this is the full code i change in 2 file, it is just temporly work around, hope somebody could rewrite the mongoAuthState to save the key and read the key correctly in array and handle the buffer data correctly
Downloads.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions