Fix reaction display in private MUCs
This commit is contained in:
parent
9e11bef219
commit
921f28c84b
|
@ -323,6 +323,14 @@ public class MucManager : StreamInteractionModule, Object {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Jid? get_occupant_jid(Account account, Jid room, Jid occupant_real_jid) {
|
||||||
|
Xep.Muc.Flag? flag = get_muc_flag(account);
|
||||||
|
if (flag != null) {
|
||||||
|
return flag.get_occupant_jid(occupant_real_jid, room);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Xep.Muc.Role? get_role(Jid jid, Account account) {
|
public Xep.Muc.Role? get_role(Jid jid, Account account) {
|
||||||
Xep.Muc.Flag? flag = get_muc_flag(account);
|
Xep.Muc.Flag? flag = get_muc_flag(account);
|
||||||
if (flag != null) {
|
if (flag != null) {
|
||||||
|
|
|
@ -199,6 +199,7 @@ public class Dino.Reactions : StreamInteractionModule, Object {
|
||||||
.with(db.reaction.account_id, "=", account.id)
|
.with(db.reaction.account_id, "=", account.id)
|
||||||
.with(db.reaction.content_item_id, "=", content_item.id)
|
.with(db.reaction.content_item_id, "=", content_item.id)
|
||||||
.outer_join_with(db.occupantid, db.occupantid.id, db.reaction.occupant_id)
|
.outer_join_with(db.occupantid, db.occupantid.id, db.reaction.occupant_id)
|
||||||
|
.outer_join_with(db.jid, db.jid.id, db.reaction.jid_id)
|
||||||
.order_by(db.reaction.time, "DESC");
|
.order_by(db.reaction.time, "DESC");
|
||||||
|
|
||||||
string? own_occupant_id = stream_interactor.get_module(MucManager.IDENTITY).get_own_occupant_id(account, content_item.jid);
|
string? own_occupant_id = stream_interactor.get_module(MucManager.IDENTITY).get_own_occupant_id(account, content_item.jid);
|
||||||
|
@ -209,11 +210,17 @@ public class Dino.Reactions : StreamInteractionModule, Object {
|
||||||
string emoji_str = row[db.reaction.emojis];
|
string emoji_str = row[db.reaction.emojis];
|
||||||
|
|
||||||
Jid jid = null;
|
Jid jid = null;
|
||||||
if (row[db.occupantid.occupant_id] == own_occupant_id) {
|
if (!db.jid.bare_jid.is_null(row)) {
|
||||||
jid = account.bare_jid;
|
jid = new Jid(row[db.jid.bare_jid]);
|
||||||
|
} else if (!db.occupantid.occupant_id.is_null(row)) {
|
||||||
|
if (row[db.occupantid.occupant_id] == own_occupant_id) {
|
||||||
|
jid = account.bare_jid;
|
||||||
|
} else {
|
||||||
|
string nick = row[db.occupantid.last_nick];
|
||||||
|
jid = content_item.jid.with_resource(nick);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
string nick = row[db.occupantid.last_nick];
|
warning("Reaction with neither JID nor occupant id");
|
||||||
jid = content_item.jid.with_resource(nick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string emoji in emoji_str.split(",")) {
|
foreach (string emoji in emoji_str.split(",")) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Dino {
|
||||||
if (conversation.type_ == Conversation.Type.CHAT) {
|
if (conversation.type_ == Conversation.Type.CHAT) {
|
||||||
return get_real_display_name(stream_interactor, conversation.account, participant, self_word) ?? participant.bare_jid.to_string();
|
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 get_occupant_display_name(stream_interactor, conversation, participant);
|
||||||
}
|
}
|
||||||
return participant.bare_jid.to_string();
|
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) {
|
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) {
|
if (muc_real_name) {
|
||||||
MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY);
|
MucManager muc_manager = stream_interactor.get_module(MucManager.IDENTITY);
|
||||||
if (muc_manager.is_private_room(conversation.account, jid.bare_jid)) {
|
if (muc_manager.is_private_room(conversation.account, conversation.counterpart)) {
|
||||||
Jid? real_jid = muc_manager.get_real_jid(jid, conversation.account);
|
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) {
|
if (real_jid != null) {
|
||||||
string? display_name = get_real_display_name(stream_interactor, conversation.account, real_jid, self_word);
|
string? display_name = get_real_display_name(stream_interactor, conversation.account, real_jid, self_word);
|
||||||
if (display_name != null) return display_name;
|
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();
|
return jid.resourcepart ?? jid.to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,6 +26,15 @@ public class Flag : XmppStreamFlag {
|
||||||
|
|
||||||
public Jid? get_real_jid(Jid full_jid) { return occupant_real_jids[full_jid]; }
|
public Jid? get_real_jid(Jid full_jid) { return occupant_real_jids[full_jid]; }
|
||||||
|
|
||||||
|
public Jid? get_occupant_jid(Jid real_jid, Jid room) {
|
||||||
|
foreach (Map.Entry<Jid, Jid> entry in occupant_real_jids) {
|
||||||
|
if (entry.value.equals_bare(real_jid) && entry.key.equals_bare(room)) {
|
||||||
|
return entry.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Gee.List<Jid> get_offline_members(Jid muc_jid) {
|
public Gee.List<Jid> get_offline_members(Jid muc_jid) {
|
||||||
Gee.List<Jid> ret = new ArrayList<Jid>(Jid.equals_func);
|
Gee.List<Jid> ret = new ArrayList<Jid>(Jid.equals_func);
|
||||||
HashMap<Jid, Affiliation>? muc_affiliations = affiliations[muc_jid.bare_jid];
|
HashMap<Jid, Affiliation>? muc_affiliations = affiliations[muc_jid.bare_jid];
|
||||||
|
|
Loading…
Reference in a new issue