From 1004a4005d04e6bf41c255fc2fc54a07ede1b006 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Fri, 11 Sep 2015 21:32:49 +0200 Subject: [PATCH] Fix user names not being displayed in group chats Add users to temporary group "Telegram Foreign", to assure that the user alias is always known to Pidgin. Don't store this group permanently but drop it when closing. --- tgp-2prpl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tgp-2prpl.c b/tgp-2prpl.c index 8e07a73..aab0ee9 100644 --- a/tgp-2prpl.c +++ b/tgp-2prpl.c @@ -116,6 +116,22 @@ void p2tgl_got_chat_left (struct tgl_state *TLS, tgl_peer_id_t chat) { void p2tgl_got_chat_in (struct tgl_state *TLS, tgl_peer_id_t chat, tgl_peer_id_t who, const char *message, int flags, time_t when) { char *name = p2tgl_strdup_id (who); + + // Make sure that the participant exists in the blist, so that the correct print name of + // the chat is being displayed by libpurple + connection_data *conn = TLS->ev_base; + PurpleBuddy *buddy = buddy = purple_find_buddy (conn->pa, name); + if (! buddy) { + buddy = purple_buddy_new (conn->pa, name, tgl_peer_get(TLS, who)->print_name); + PurpleGroup *group = purple_find_group ("Telegram Foreign"); + if (!group) { + group = purple_group_new ("Telegram Foreign"); + purple_blist_add_group (group, NULL); + purple_blist_node_set_flags (&group->node, PURPLE_BLIST_NODE_FLAG_NO_SAVE); + } + purple_blist_add_buddy (buddy, NULL, group, NULL); + purple_blist_node_set_flags (&buddy->node, PURPLE_BLIST_NODE_FLAG_NO_SAVE); + } serv_got_chat_in (tg_get_conn(TLS), tgl_get_peer_id (chat), name, flags, message, when);