hoehermann / purple-gowhatsapp

Pidgin/libpurple plugin for WhatsApp Web.
GNU General Public License v3.0
277 stars 34 forks source link

whatsmeow: missing contacts #105

Closed jeremyp3 closed 2 years ago

jeremyp3 commented 2 years ago

hi,

when I run whatsmeow it only fetches 8 contacts when I easily have around 30 or more.

I tried to find a logic, but I couldn't find any. I originally thought it would only fetch contacts I've had recent chats with, but that idea isn't good because I have at least 1 contact I've never chatted with.

since the box "checked Display offline contacts as away" is checked, I thought that all my contacts would appear as absent... but this is not the case...

I specify that even if I redo a connection from scratch, I always have the same 8 contacts who come back

the log does not seem abnormal to me

do you have a suggestion for me?

thanks!

Jeremyp3

hoehermann commented 2 years ago

Thank you for the report.

As far as I can tell, contacts are only downloaded in bulk once. That is right after linking. In the logs, there should be a line which says "history sync" followed by a number of lines regarding the individual contacts. If the contact is not listed there, the WhatsApp servers do not send them. Can you log out of the account (delete in Pidgin or unlink via phone) and look for the contacts in the log?

There is a feature https://godocs.io/go.mau.fi/whatsmeow#Client.FetchAppState which allows requesting the current list of contacts without re-linking. I can put it on the list of possible improvements.

jeremyp3 commented 2 years ago

it is impossible to debug during a connection :( when I do it through the debug window or with -d /tmp/pidgin-debug.txt, pidgin crashes with the message: "(20:26:04) signals: Signal data for bitlbee-set-account-password not found! (20:26:04) whatsmeow: [Client/Send] <iq id="2193353903" to="s.whatsapp.net" type="result"><device-identity key-index="6"> (20:26:04) Gtk: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created. You must use marks, character numbers, or line numbers to preserve a position across buffer modifications. You can apply tags and insert marks without invalidating your iterators, but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset) will invalidate all outstanding iterators (20:26:04) Gtk: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created. You must use marks, character numbers, or line numbers to preserve a position across buffer modifications. You can apply tags and insert marks without invalidating your iterators, but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset) will invalidate all outstanding iterators

(process:2918): Gtk-WARNING (recursed) **: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created. You must use marks, character numbers, or line numbers to preserve a position across buffer modifications. You can apply tags and insert marks without invalidating your iterators, but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset) will invalidate all outstanding iterators"

hoehermann commented 2 years ago

Although that does not immediately help in investigating the missing contacts, it shows I am probably having an error in my memory management somewhere. Good you found that bug. I usually examine debug messages on the console and would never have noticed. I want to look into it.

hoehermann commented 2 years ago

I was able to reproduce the issue. It is caused by purple_signal_emit. I guarded it in the protocol bridge compatibility mode so it should not bother Pidgin users any longer. @jeremyp3 Does this change anything for you?

@EionRobb Do you happen to know anything about this? Could this be a bug in GTK?

@yourealwaysbe I renamed the setting name "spectrum-compatibility" to "bridge-compatibility". It is mandatory for bitlbee now.

Also, I am now querying the current list of WhatsApp groups every connect. Participant lists are filled.

jeremyp3 commented 2 years ago

Oops sorry, since you have edited your comment I did not receive an email.

Now I do not have the pidgin crash but I still have 8 contact, and I have two groups that have added themselves.

In my pidgin's log, I have that for every contact that I can see: (12:20:52) Whatsmeow: Recieved Name (SubType 0) for Account 0x5650B83xxx Remote @. (NULL) (AKA name, Frome 0) SENT 0: (null) (12:20:52) Blist: Updating Buddy Status for @. (WhatsApp (Whatsmeow)) (12:20:52) Blist: Updating Buddy Status for @.*** (WhatsApp (Whatsmeow))

Do I have to look at something in particular?

thanks !

Jerem

hoehermann commented 2 years ago

The "received name" lines tell me that whatsmeow is indeed feeding contacts into Pidgin, working as indented. If the WhatsApp servers decide not to send more contacts, then there is – as far as I know – nothing I can do about it.

Please note that "contacts stored on your phone" and "contacts stored on WhatsApp servers" may differ. As far as I can tell, the WhatsApp servers only send contacts I have had a conversation with within the last couple of weeks. That is why for me it is the other way around: My Pidgin buddy list has more contacts than WhatsApp is sending.

jeremyp3 commented 2 years ago

For me, there is no coherence

Pidgin shows me that 8 contacts and among them:

In addition, some with whom I have already discussed a few months ago are not present in the Pidgin list.

If in whatsapp, I click on "new discussion" I have many more contacts ... so whatsapp consider all my contacts ...

could my log help debug? I can send it privately

hoehermann commented 2 years ago

Yes, you can do that. Best start pidgin from command-line (bash, powershell or cmd) with pidgin -d > pidgin.log and then send me the logfile to github@hehoe.de.

I just published a new version which explicitly requests fetching contacts after every connect. Contacts are forwarded to the buddy list, if enabled. This might also be interesting for bitlbee @yourealwaysbe.

yourealwaysbe commented 2 years ago

The contact fetching appears to be working for me, thanks! It now force-opens group chats, which it didn't before. Was that deliberate (it's a little annoying)?

jeremyp3 commented 2 years ago

With this version, I have my 53 contacts that appear.

I think the contacts I received so far were the contacts that have defined an explicit name in Whatsappp, because the other contacts I have, I only see the phone number with the suffix @ S.Whatsapp .net.

I do not know if it's normal because it seemed to me that we had to define a name to the creation of the account in whatsapp, but if it is normal, I rename my contacts by hand

log: [...] (23:13:13) whatsmeow: recieved name (subtype 0) for account 0x56334xxxxxxx remote @. (isGroup 0) sender (null) (alias , fromMe 0) sent 0: (null) (23:13:13) whatsmeow: recieved name (subtype 0) for account 0x56334xxxxxx remote @. (isGroup 0) sender (null) (alias , fromMe 0) sent 0: (null) (23:13:13) whatsmeow: recieved name (subtype 0) for account 0x563xxxxxx remote @.*** (isGroup 0) sender (null) (alias Corentin, fromMe 0) sent 0: (null)

For example, the last contact with an alias, I received it before the update

thanks for the fix !

hoehermann commented 2 years ago

It now force-opens group chats, which it didn't before. Was that deliberate (it's a little annoying)?

Yes. I thought that was necessary to re-establish the chat after connecting. Maybe I confused it with the behaviour expected by spectrum. I want to move it to a separate setting.

the other contacts I have, I only see the phone number with the suffix

That explains why it did not work before. I only added contacts to the buddy list if I had received a name.

thanks for the fix !

You are welcome. Thank you for the testing. :)

jeremyp3 commented 2 years ago

After resetting my account on pidgin, I am having the same problem I reported on this issue.

I only retrieve 8 contacts in pidgin, the same as before, so a priori those who have a nickname to declare in whatsapp. the others are no longer present :( I can recover my contacts, if I go back a few commits.

hoehermann commented 2 years ago

Which commit is the one that works for you and which one is not?

jeremyp3 commented 2 years ago

the commit from which I have the problem when I create my account on pidgin is: f0948368f4ae4b3 "Date: Thu Feb 17 23:52:47 2022 +0100" before the commit is ok.

jeremyp3 commented 2 years ago

after changing to available status on pidgin my contacts came back.

hoehermann commented 2 years ago

Okay. I want to change the conditions so contacts are requested when setting any status, not only "available".