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

one bug fixed about group message #793

Open
xinkyo opened this issue Sep 6, 2023 · 1 comment
Open

one bug fixed about group message #793

xinkyo opened this issue Sep 6, 2023 · 1 comment

Comments

@xinkyo
Copy link

xinkyo commented Sep 6, 2023

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

@luanhduarte
Copy link

Is it working?
I added these two files in my code and it's not working!

Take a look in the API's answer:

{
"error": true,
"code": 500,
"message": "Error: NoSessionException"
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants