hoehermann / purple-signald

Pidgin libpurple bridge to signald.
GNU General Public License v3.0
153 stars 19 forks source link

Look up names of group chat participants not on buddy list #83

Closed mike-gh closed 1 year ago

mike-gh commented 1 year ago

I use the plugin and am in a number of group chats. Some of the buddies are listed by name but others are listed by their UUID. I have listed the room members via signalctl and it does list a uuid and name for each member. However, in Pidgin the UUID is used for some members. If I right click a user and select Info, the only common theme I can see is that if the user is listed by name, then the Name field is NOT populated in Info. If the user is listed by UUID, then the Name field IS populated. I know that seems strange :-)

In both cases, the profile_name is populated in Info.

hoehermann commented 1 year ago

Hi Mike

Thank you for the bug report. Before we can start with further investigation, I need to explain some terminology:

In Pidgin:

In Signal/Signald:

In essence, what is the name in Pidgin is the UUID in Signald. The alias may be any of the profile's name fields.

I am taking a lot of short-cuts. The plug-in is lazy. I rely on Pidgin's implicit features to resolve the UUID to what I like to call "friendly name". This method only works if the contact is on the buddy list. That means:

Group chat participants which are on the buddy list are displayed with their "friendly name".
Group chat participants which are not on the buddy list are displayed with their UUID.

Kind Regards
Hermann

Can you check whether, for your case, my theory is correct?

mike-gh commented 1 year ago

Hi Hermann,

Thanks for the feedback. Unfortunately it's been a while since I installed both Signal and your plugin, so my recollection of events may not be correct but I believe the following to be what happened:

I was using another messaging platform and the users decided to migrate to Signal, necessitating that I install Signal on my phone. After this I was invited to join a couple of other groups. Other than a couple of contacts, I don't believe I've messaged anyone directly on Signal. Nevertheless, I have a whole load of users, who appear by name in the group chats on my Buddy list. I think I just installed the plugin and they appeared, I don't recall adding anyone, in fact, there are names in the Buddy list and I have no idea who they are!

As a further test to the Buddy list theory, I selected one lucky individual who is listed by UUID in one of my group chats and I added them to the Buddy list. They are now in my buddy list, listed by UUID.

From what I can tell, that doesn't seem consistent with the Buddy list theory.

Kind Regards, Mike.

hoehermann commented 1 year ago

They are now in my buddy list, listed by UUID.

When the plug-in connects, it queries the Signal for all contacts known by the current account. By default, they are added to the buddy list automatically. It looks like the contacts who you do not have a direct conversation with are not part of that list

In theory, I could do a look-up: For each group chat participant, if they are not on the local buddy list, then the plug-in could request the profile details. Unfortunately, in the past, that has triggered some rate-limiting mechanisms imposed by Signal servers. I need to have a cache for storing non-buddy names. I am unwilling to add that feature right now.

In the mean-time, there is a workaround:

Have a group chat with participants listed with UUIDs:
default

Add the participant (21… in this example) to your local buddy list and enter their name ("Es…" in this example) manually. The name will then be picked up the next time you open the group chat:
added_with_alias

mike-gh commented 1 year ago

I have tried adding the contacts to my buddy list and they now show by name in the chat, so the workaround works!

One thing: I noticed when running "signaldctl group show " that all the members are listed in a table with their phone number, uuid and name. I wonder if it would be possible for your plugin to request this info from signald without having to worry about rate limits and caching?

hoehermann commented 1 year ago

the workaround works!

I am glad it is working.

Thank you for the suggestion. I was not aware of the detailed output of that feature. I need to look up how signaldctl does it internally. In the documented API JsonGroupV2Info only offers a collection of members. They only show the UUID (and maybe the number).

Also, I need to find out how to provide the display name to the Pidgin group chat window. Would it be okay for you if I added the chat participants to the buddy list?

mike-gh commented 1 year ago

I have several messaging apps aggregated into Pidgin. Each one has a group eg Buddies, Signal. etc which groups the buddies by app. I think it would perhaps be better to put them into a buddy group called Signal or something similar. Though I think ideally adding buddies to the buddy list should be separate, if possible. I think looking at how signaldctl gets its info would be the best place to start.

hoehermann commented 1 year ago

Though I think ideally adding buddies to the buddy list should be separate, if possible.

That is possible and sounds reasonable.

I need to look up how signaldctl does it internally.

signaldctl actually does a GetProfileRequest on every participant. It looks like we can do that now.

I have a lot on my schedule currently, so no estimate on when I will implement it, though.

hoehermann commented 1 year ago

Implemented in 7af0740.