aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
Diffstat (limited to 'libdino')
-rw-r--r--libdino/src/service/conversation_manager.vala17
-rw-r--r--libdino/src/service/counterpart_interaction_manager.vala8
2 files changed, 17 insertions, 8 deletions
diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala
index dcb0ced4..8b33f52f 100644
--- a/libdino/src/service/conversation_manager.vala
+++ b/libdino/src/service/conversation_manager.vala
@@ -84,15 +84,20 @@ public class ConversationManager : StreamInteractionModule, Object {
return null;
}
- public Conversation? approx_conversation_for_stanza(Jid jid, Account account, string msg_ty) {
+ public Conversation? approx_conversation_for_stanza(Jid from, Jid to, Account account, string msg_ty) {
if (msg_ty == Xmpp.MessageStanza.TYPE_GROUPCHAT) {
- return get_conversation(jid.bare_jid, account, Conversation.Type.GROUPCHAT);
- } else if (msg_ty == Xmpp.MessageStanza.TYPE_CHAT && jid.is_full() &&
- get_conversation(jid.bare_jid, account, Conversation.Type.GROUPCHAT) != null) {
- var pm = get_conversation(jid, account, Conversation.Type.GROUPCHAT_PM);
+ return get_conversation(from.bare_jid, account, Conversation.Type.GROUPCHAT);
+ }
+
+ Jid counterpart = from.equals_bare(account.bare_jid) ? to : from;
+
+ if (msg_ty == Xmpp.MessageStanza.TYPE_CHAT && counterpart.is_full() &&
+ get_conversation(counterpart.bare_jid, account, Conversation.Type.GROUPCHAT) != null) {
+ var pm = get_conversation(counterpart, account, Conversation.Type.GROUPCHAT_PM);
if (pm != null) return pm;
}
- return get_conversation(jid.bare_jid, account, Conversation.Type.CHAT);
+
+ return get_conversation(counterpart.bare_jid, account, Conversation.Type.CHAT);
}
public Conversation? get_conversation_by_id(int id) {
diff --git a/libdino/src/service/counterpart_interaction_manager.vala b/libdino/src/service/counterpart_interaction_manager.vala
index 7776b885..5b9d1fff 100644
--- a/libdino/src/service/counterpart_interaction_manager.vala
+++ b/libdino/src/service/counterpart_interaction_manager.vala
@@ -95,7 +95,7 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
// Don't show our own (other devices) typing notification
if (jid.equals_bare(account.bare_jid)) return;
- Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(jid, account, stanza.type_);
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(stanza.from, stanza.to, account, stanza.type_);
if (conversation == null) return;
// Don't show our own typing notification in MUCs
@@ -118,7 +118,7 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
}
private async void on_chat_marker_received(Account account, Jid jid, string marker, string stanza_id, MessageStanza message_stanza) {
- Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(jid, account, message_stanza.type_);
+ Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).approx_conversation_for_stanza(message_stanza.from, message_stanza.to, account, message_stanza.type_);
if (conversation == null) return;
handle_chat_marker(conversation, jid, marker, stanza_id);
}
@@ -141,6 +141,10 @@ public class CounterpartInteractionManager : StreamInteractionModule, Object {
Entities.Message? message = null;
if (conversation.type_ == Conversation.Type.GROUPCHAT || conversation.type_ == Conversation.Type.GROUPCHAT_PM) {
message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_server_id(stanza_id, conversation);
+ // Outdated clients might use the message id. Or in MUCs that don't send server ids.
+ if (message == null) {
+ message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_stanza_id(stanza_id, conversation);
+ }
} else {
message = stream_interactor.get_module(MessageStorage.IDENTITY).get_message_by_stanza_id(stanza_id, conversation);
}