diff options
Diffstat (limited to 'main/src/ui/util/helper.vala')
-rw-r--r-- | main/src/ui/util/helper.vala | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 8d9fee53..ca2c37d9 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -124,7 +124,7 @@ public static string get_conversation_display_name(StreamInteractor stream_inter return get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart); } if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) { - return _("%s from %s").printf(get_occupant_display_name(stream_interactor, conversation.account, conversation.counterpart), get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart.bare_jid)); + return _("%s from %s").printf(get_occupant_display_name(stream_interactor, conversation, conversation.counterpart), get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart.bare_jid)); } return conversation.counterpart.to_string(); } @@ -141,7 +141,7 @@ public static string get_participant_display_name(StreamInteractor stream_intera return get_real_display_name(stream_interactor, conversation.account, participant, me_is_me) ?? participant.bare_jid.to_string(); } if ((conversation.type_ == Conversation.Type.GROUPCHAT || conversation.type_ == Conversation.Type.GROUPCHAT_PM) && conversation.counterpart.equals_bare(participant)) { - return get_occupant_display_name(stream_interactor, conversation.account, participant); + return get_occupant_display_name(stream_interactor, conversation, participant); } return participant.bare_jid.to_string(); } @@ -182,17 +182,26 @@ private static string get_groupchat_display_name(StreamInteractor stream_interac return jid.to_string(); } -private static string get_occupant_display_name(StreamInteractor stream_interactor, Account account, Jid jid, bool me_is_me = false, bool muc_real_name = false) { +private static string get_occupant_display_name(StreamInteractor stream_interactor, Conversation conversation, Jid jid, bool me_is_me = false, bool muc_real_name = false) { if (muc_real_name) { MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY); - if (muc_manager.is_private_room(account, jid.bare_jid)) { - Jid? real_jid = muc_manager.get_real_jid(jid, account); + if (muc_manager.is_private_room(conversation.account, jid.bare_jid)) { + Jid? real_jid = muc_manager.get_real_jid(jid, conversation.account); if (real_jid != null) { - string? display_name = get_real_display_name(stream_interactor, account, real_jid, me_is_me); + string? display_name = get_real_display_name(stream_interactor, conversation.account, real_jid, me_is_me); if (display_name != null) return display_name; } } } + + // If it's us (jid=our real full JID), display our nick + if (conversation.type_ == Conversation.Type.GROUPCHAT_PM && conversation.account.bare_jid.equals_bare(jid)) { + var muc_conv = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(conversation.counterpart.bare_jid, conversation.account, Conversation.Type.GROUPCHAT); + if (muc_conv != null && muc_conv.nickname != null) { + return muc_conv.nickname; + } + } + return jid.resourcepart ?? jid.to_string(); } |