Recognize own MUC messages from other device
This commit is contained in:
parent
81310dff2e
commit
c8f68678be
|
@ -94,13 +94,17 @@ public class MessageProcessor : StreamInteractionModule, Object {
|
||||||
Entities.Message new_message = new Entities.Message(message.body);
|
Entities.Message new_message = new Entities.Message(message.body);
|
||||||
new_message.account = account;
|
new_message.account = account;
|
||||||
new_message.stanza_id = message.id;
|
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))) {
|
Jid? counterpart_override = null;
|
||||||
new_message.direction = Entities.Message.DIRECTION_RECEIVED;
|
if (message.from.equals(stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(message.from.bare_jid, account))) {
|
||||||
} else {
|
|
||||||
new_message.direction = Entities.Message.DIRECTION_SENT;
|
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.ourpart = new_message.direction == Entities.Message.DIRECTION_SENT ? message.from : message.to;
|
||||||
new_message.stanza = message;
|
new_message.stanza = message;
|
||||||
|
|
||||||
|
|
|
@ -347,15 +347,19 @@ public class MucManager : StreamInteractionModule, Object {
|
||||||
message.real_jid = real_jid.bare_jid;
|
message.real_jid = real_jid.bare_jid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string? muc_nick = stream.get_flag(Xep.Muc.Flag.IDENTITY).get_muc_nick(conversation.counterpart.bare_jid);
|
Jid? own_muc_jid = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(message.counterpart.bare_jid, conversation.account);
|
||||||
if (muc_nick != null && message.from.equals(new Jid(@"$(message.from.bare_jid)/$muc_nick"))) { // TODO better from own
|
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);
|
Gee.List<Entities.Message> messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation);
|
||||||
foreach (Entities.Message m in messages) { // TODO not here
|
foreach (Entities.Message m in messages) { // TODO not here
|
||||||
if (m.equals(message)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue