Fix message duplication in MUC PMs
This commit is contained in:
parent
2d31d9d470
commit
b60e7da28a
|
@ -81,7 +81,7 @@ public class Message : Object {
|
||||||
if (counterpart_resource != null) counterpart = counterpart.with_resource(counterpart_resource);
|
if (counterpart_resource != null) counterpart = counterpart.with_resource(counterpart_resource);
|
||||||
|
|
||||||
string our_resource = row[db.message.our_resource];
|
string our_resource = row[db.message.our_resource];
|
||||||
if (type_.is_muc_semantic() && our_resource != null) {
|
if (type_ == Type.GROUPCHAT && our_resource != null) {
|
||||||
ourpart = counterpart.with_resource(our_resource);
|
ourpart = counterpart.with_resource(our_resource);
|
||||||
} else if (our_resource != null) {
|
} else if (our_resource != null) {
|
||||||
ourpart = account.bare_jid.with_resource(our_resource);
|
ourpart = account.bare_jid.with_resource(our_resource);
|
||||||
|
|
|
@ -598,7 +598,7 @@ public class MessageProcessor : StreamInteractionModule, Object {
|
||||||
message.local_time = now;
|
message.local_time = now;
|
||||||
message.direction = Entities.Message.DIRECTION_SENT;
|
message.direction = Entities.Message.DIRECTION_SENT;
|
||||||
message.counterpart = conversation.counterpart;
|
message.counterpart = conversation.counterpart;
|
||||||
if (conversation.type_.is_muc_semantic()) {
|
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||||
message.ourpart = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account) ?? conversation.account.bare_jid;
|
message.ourpart = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account) ?? conversation.account.bare_jid;
|
||||||
message.real_jid = conversation.account.bare_jid;
|
message.real_jid = conversation.account.bare_jid;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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);
|
return get_groupchat_display_name(stream_interactor, conversation.account, conversation.counterpart);
|
||||||
}
|
}
|
||||||
if (conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
|
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();
|
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();
|
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)) {
|
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();
|
return participant.bare_jid.to_string();
|
||||||
}
|
}
|
||||||
|
@ -182,17 +182,26 @@ private static string get_groupchat_display_name(StreamInteractor stream_interac
|
||||||
return jid.to_string();
|
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) {
|
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(account, jid.bare_jid)) {
|
if (muc_manager.is_private_room(conversation.account, jid.bare_jid)) {
|
||||||
Jid? real_jid = muc_manager.get_real_jid(jid, account);
|
Jid? real_jid = muc_manager.get_real_jid(jid, conversation.account);
|
||||||
if (real_jid != null) {
|
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 (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();
|
return jid.resourcepart ?? jid.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue