aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/util
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2023-01-31 14:43:17 +0100
committerMarvin W <git@larma.de>2023-01-31 15:14:55 +0100
commit921f28c84bbda56ec93df7dcde7c828eaabb0b58 (patch)
tree78c9276d47d6d939e242e072032b9196b5a8c6c6 /libdino/src/util
parent9e11bef219880b5bdc5d299c31ec6249596a86ba (diff)
downloaddino-921f28c84bbda56ec93df7dcde7c828eaabb0b58.tar.gz
dino-921f28c84bbda56ec93df7dcde7c828eaabb0b58.zip
Fix reaction display in private MUCs
Diffstat (limited to 'libdino/src/util')
-rw-r--r--libdino/src/util/display_name.vala20
1 files changed, 17 insertions, 3 deletions
diff --git a/libdino/src/util/display_name.vala b/libdino/src/util/display_name.vala
index 0c05eda8..d99bc40b 100644
--- a/libdino/src/util/display_name.vala
+++ b/libdino/src/util/display_name.vala
@@ -30,7 +30,7 @@ namespace Dino {
if (conversation.type_ == Conversation.Type.CHAT) {
return get_real_display_name(stream_interactor, conversation.account, participant, self_word) ?? participant.bare_jid.to_string();
}
- if ((conversation.type_ == Conversation.Type.GROUPCHAT || conversation.type_ == Conversation.Type.GROUPCHAT_PM) && conversation.counterpart.equals_bare(participant)) {
+ if ((conversation.type_ == Conversation.Type.GROUPCHAT || conversation.type_ == Conversation.Type.GROUPCHAT_PM)) {
return get_occupant_display_name(stream_interactor, conversation, participant);
}
return participant.bare_jid.to_string();
@@ -75,8 +75,13 @@ namespace Dino {
public static string get_occupant_display_name(StreamInteractor stream_interactor, Conversation conversation, Jid jid, string? self_word = null, bool muc_real_name = false) {
if (muc_real_name) {
MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY);
- if (muc_manager.is_private_room(conversation.account, jid.bare_jid)) {
- Jid? real_jid = muc_manager.get_real_jid(jid, conversation.account);
+ if (muc_manager.is_private_room(conversation.account, conversation.counterpart)) {
+ Jid? real_jid = null;
+ if (jid.equals_bare(conversation.counterpart)) {
+ muc_manager.get_real_jid(jid, conversation.account);
+ } else {
+ real_jid = jid;
+ }
if (real_jid != null) {
string? display_name = get_real_display_name(stream_interactor, conversation.account, real_jid, self_word);
if (display_name != null) return display_name;
@@ -92,6 +97,15 @@ namespace Dino {
}
}
+ // If it's someone else's real jid, recover nickname
+ if (!jid.equals_bare(conversation.counterpart)) {
+ MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY);
+ Jid? occupant_jid = muc_manager.get_occupant_jid(conversation.account, conversation.counterpart.bare_jid, jid);
+ if (occupant_jid != null && occupant_jid.resourcepart != null) {
+ return occupant_jid.resourcepart;
+ }
+ }
+
return jid.resourcepart ?? jid.to_string();
}
} \ No newline at end of file