aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/message_processor.vala14
-rw-r--r--libdino/src/service/muc_manager.vala10
2 files changed, 16 insertions, 8 deletions
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index f2f539bb..14db0132 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -94,13 +94,17 @@ public class MessageProcessor : StreamInteractionModule, Object {
Entities.Message new_message = new Entities.Message(message.body);
new_message.account = account;
new_message.stanza_id = message.id;
- if (!account.bare_jid.equals_bare(message.from) ||
- message.from.equals(stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(message.from.bare_jid, account))) {
- new_message.direction = Entities.Message.DIRECTION_RECEIVED;
- } else {
+
+ Jid? counterpart_override = null;
+ if (message.from.equals(stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(message.from.bare_jid, account))) {
new_message.direction = Entities.Message.DIRECTION_SENT;
+ counterpart_override = message.from.bare_jid;
+ } else if (account.bare_jid.equals_bare(message.from)) {
+ new_message.direction = Entities.Message.DIRECTION_SENT;
+ } else {
+ new_message.direction = Entities.Message.DIRECTION_RECEIVED;
}
- new_message.counterpart = new_message.direction == Entities.Message.DIRECTION_SENT ? message.to : message.from;
+ new_message.counterpart = counterpart_override ?? (new_message.direction == Entities.Message.DIRECTION_SENT ? message.to : message.from);
new_message.ourpart = new_message.direction == Entities.Message.DIRECTION_SENT ? message.from : message.to;
new_message.stanza = message;
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala
index 60dc0446..8b5b8e7f 100644
--- a/libdino/src/service/muc_manager.vala
+++ b/libdino/src/service/muc_manager.vala
@@ -347,15 +347,19 @@ public class MucManager : StreamInteractionModule, Object {
message.real_jid = real_jid.bare_jid;
}
}
- string? muc_nick = stream.get_flag(Xep.Muc.Flag.IDENTITY).get_muc_nick(conversation.counterpart.bare_jid);
- if (muc_nick != null && message.from.equals(new Jid(@"$(message.from.bare_jid)/$muc_nick"))) { // TODO better from own
+ Jid? own_muc_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(message.counterpart.bare_jid, conversation.account);
+ if (own_muc_jid != null && message.from.equals(own_muc_jid)) {
Gee.List<Entities.Message> messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation);
foreach (Entities.Message m in messages) { // TODO not here
if (m.equals(message)) {
- m.marked = Entities.Message.Marked.RECEIVED;
+ // For own messages from this device (msg is a duplicate)
+ m.marked = Message.Marked.RECEIVED;
}
}
}
+ // For own messages from other devices (msg is not a duplicate msg)
+ message.marked = Message.Marked.RECEIVED;
+
return false;
}
}