-
Notifications
You must be signed in to change notification settings - Fork 191
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
Hangups fails to find all contact names #4
Comments
Have a look at the code that parses the contacts: The format is pretty strange, so it's likely missing some contacts. |
That commit actually causes a similar failure mode for me - one of my conversations seems to have neither a first_name nor a full_name associated with it, so both https://github.com/tdryer/hangups/blob/master/hangups/client.py#L142 and the line after it fail with KeyErrors on HEAD = ce88f81 That said, this is awesome work! EDIT: Okay, so looking at the mobile Hangouts app, the failing conversation is a contact who I never talked to via the official Hangouts app - only via bitlbee/XMPP. Could that be it? |
Thanks for trying it out! Can you post an excerpt from hangups.log? There should be a line like this, followed by the response hangups is trying to parse: |
Well, this is that message (my sister, amusingly enough): (snipped, see EDIT2) However, that does have the display_name and first_name fields. EDIT: Oh, I see. There's multiple entities in the response, and the one that's actually at fault is not my sister. |
If I json.dumps the failed entity, it's this: |
Right, it appears to be looking up two users at once, and one of them is |
Ooooh, I think I know what happened. I think that's someone who deleted their G+ account |
Good catch. If you can guess who that is, the question is do they appear in the Hangouts app and does it know their name somehow? |
They do and it does - the hangouts app on Android orders conversations the same way as your TUI client, which makes it easy. Just find the two conversations that bracket it. |
Can you add a |
No, looks like both IDs are the same: (the second tuple being the broken one, and the first being my sister) |
If you're interested, the next step is to watch the traffic when the Hangouts Chrome extension loads to find out how it gets the name. You can press F5 while in the Chrome developer tools network tab to force the extension to reload and capture the requests. |
Ah, I don't even have Chrome installed. Firefox user here :P |
It should be possible to accomplish the same thing with Firefox's developer tools and the Hangouts widget in Gmail. |
ce88f81 should handle this now so users with no name are called |
It looks like it comes as part of the big Javascript-in-HTML dump from https://talkgadget.google.com/u/0/talkgadget/_/chat ; working on exactly what the format is. |
(or rather, where in data_dict it winds up) |
Aha! Currently, on client.py:429 you use p[0] as the tuple of user_ids - p[1] is the name of the user! |
If I move
up, and add
into the participants loop, it works perfectly, with the contact names overwriting the 'temporary' participant ones if found. |
Interesting idea, pulling the names from the conversation rather than the contact. I could almost do without all the complicated contact parsing code. Too bad it doesn't provide the first_name separately. |
Eh, the contact parsing code is valuable for when you add the ability to invite additional participants/start new chats |
This helps deal with contacts whose names can't be found by other methods (#4).
I committed that workaround. Thanks again! |
No problem! Glad I was able to track this down. |
I still have crashes due to this issue, maybe it should put some stub name ("Unknown"?) and save the iser when |
Can you paste the stacktrace? |
this code solves the issue:
|
I pushed a commit to implement that workaround. Let me know if it works. |
It works! |
Great! Thanks for trying it out. |
we've implemented a workaround for the "unknown user" issue by populating a global |
i've "merged" the workaround previously posted into a hangups fork for testing purposes, the latest commit being this: endofline@3726795 (https://github.com/endofline/hangups/tree/workaround/fallback-user) |
Add method build_user_list which both constructs a UserList and requests data for users that are missing from the initial data. See #4.
Thanks @endofline! I've added a new function |
@tdryer i just pulled and built the latest master, the user list still seems to contain "Unknown" , but no longer has "unknown". do you require additional logs for debugging? |
my mistake again @tdryer - didn't examine the change at
to
And the _on_connect() is now a coroutine as well. Since the bot is based on the reference client, we will also have to follow suit. After applying the changes, it appears that only 1 Unknown shows up now - a person with a deleted G+ profile |
Do you get any "Adding fallback User" warnings any more? I'm curious whether that can be removed now. Unfortunately I don't have any contacts with a deleted G+ profile, so I can't debug that. |
No more "adding fallback user"s - the userlist appears clean now (except for that missing g+ profile), haven't quite tested membership changes yet |
is there a way to force an already installed version of hangups to re "build_user_list"? about 90% of my contacts show up as just the phone numbers. running the latest version of hangups. |
The user list is rebuilt every time hangups is started. If those are Google Voice contacts, you're probably affected by #52. |
@wakest @tdryer Any GVoice contacts (that is, phone numbers) won't show up because Hangouts secretly queries Google's People API to populate their data. The People API is what is supposed to replace the old Contacts API and is currently get-only and returns a subset of your contacts. I would suggest looking into that API to get information about a phone number, or, if developing a local client and there's an API for local contacts, query that. |
@avaidyam I do this in the purple-hangouts plugin, but then there's a weird cascading priority of display names - do you take the ones in the People/Contacts API or the "get entity by id" list or the Hangouts conversation object fallback name as authoritative? Gets messy. |
@EionRobb You'd prioritize the People API, only for the GVoice, and let the Hangouts API handle GAIA entities (basically, Google+ profiles). I've noticed other chat clients having this issue as well, but the GAIA stuff really comes down to preferring Google+ profile settings or a user's personal contacts information. A user may or may not correctly format contact data and it may or may not be synchronized with Google+ or Facebook. It's a policy you'd need to think about. |
I get KeyError in on_connect() method in
__main__.py
when hangups tries to get user names for user_ids in conversations:It works if I change it to:
But then I have a lot of UNKNOWN user names in list of conversations.
The text was updated successfully, but these errors were encountered: