Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadChats give null #15

Open
fabdoc opened this issue Aug 3, 2021 · 5 comments
Open

loadChats give null #15

fabdoc opened this issue Aug 3, 2021 · 5 comments

Comments

@fabdoc
Copy link

fabdoc commented Aug 3, 2021

trying to get chat count and unread messages, I query loadChats()
['query', {type: 'chat', epoch: '4'}, null]
response is
["response", {"duplicate":"true","type":"chat","status":"17931"}, null]

other requests works fine.
any help, please?

@wedjohn57
Copy link

Same here. Tried loadChats() and got null.

sendMessage() works perfect!

@tomlux
Copy link

tomlux commented Aug 16, 2021

same problem here, any workaround/fix available?

@Louuke
Copy link
Owner

Louuke commented Aug 16, 2021

Hey,
I'm sorry, but due to time constraints I'm only managing this project very infrequently.

As far as I know, the fact that WhatsApp replies with a duplicate message means that an identical message has previously been sent. Therefore it is cached in the WAMessageParser class and returned when client.loadChats() is called.

This does not work for all of you?

@fabdoc
Copy link
Author

fabdoc commented Aug 25, 2021

nope, at connection whatsapp send many message at client but not in chat format, and storedWAChats remains null.
there are difference based on android/iphone whatsapp main installation:
on android after negotiation may have chats, on iphone never....!

on iphone also load contacts is working only after a connection that require a qrcode. if i do reconnect, no contacts are given.

I suggest you to debug by modify your class backendConnector.waitForTextMessage just for test and see whitch messages came from whatsapp: (but sometimes may occur concurrent modification exeption)
now for each message received I try to parse with WAMessageParser.jsonToObjects(message);
very slower, but now i can have chats!

boolean waiting = false;
/**
* Waits until a message matching a specified string has been received from the
* onTextMessage or onBinaryMessage callback and returns it
*
* @param search
* @return
/
private String waitForTextMessage(String... search) {
while(waiting) {
Utils.waitMill(200);
}
textMessageBuffer.clear();
String foundMessage = null;
String lastMessage = null;
if(search.length > 0) {
waiting = true;
for(int i = 0; i < 200; i++) {
for(String s : search) {
for(String message : textMessageBuffer) {
System.out.println("\t
* waitForTextMessage("+s+") *************** "+i+"\n"+message);
try {
WAMessageParser.jsonToObjects(message);
} catch (Exception e) { }
if(message.contains(s)) {
foundMessage = message;
// return message;
}
if(foundMessage != null && foundMessage.equals(lastMessage)) {
i = 300;
break;
}
lastMessage = message;
}
}
Utils.waitMill(100);
}
}
waiting = false;
return foundMessage;
// return null;
}

@fabdoc
Copy link
Author

fabdoc commented Aug 26, 2021

here is an example of my response:
## sendText() ##
['query', {type: 'chat', epoch: '3'}, null]
** waitForTextMessage("type":"chat") *************** 2
793.--3,
** waitForTextMessage("type":"chat") *************** 3
793.--3,
** waitForTextMessage("type":"chat") *************** 4
793.--3,
** waitForTextMessage("type":"chat") *************** 5
...... omiss.....
["response", {"checksum":"B32939D8-421F-4743-BDBF-ABF8F70FA555","type":"contacts"}, [["user", {"jid":"[email protected]","name":"Gary xxx","short":"Gary","index":"G"}, null], ["user",
...... omiss.....
, null]]]
** waitForTextMessage("type":"chat") *************** 17
["response", {"duplicate":"true","type":"chat","status":"299750"}, null]

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

No branches or pull requests

4 participants