diff options
Diffstat (limited to 'src')
4 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index e5a2ec171..4a9a77a19 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -303,10 +303,11 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return null; } - public Message findMessageWithRemoteId(String id) { + public Message findMessageWithRemoteId(String id, Jid counterpart) { synchronized (this.messages) { for (Message message : this.messages) { - if (id.equals(message.getRemoteMsgId()) || id.equals(message.getUuid())) { + if (counterpart.equals(message.getCounterpart()) + && (id.equals(message.getRemoteMsgId()) || id.equals(message.getUuid()))) { return message; } } diff --git a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java index 4dae14757..acdaedcbe 100644 --- a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java +++ b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java @@ -170,13 +170,16 @@ public class MessageGenerator extends AbstractGenerator { return packet; } - public MessagePacket confirm(final Account account, final Jid to, final String id, final boolean groupChat) { + public MessagePacket confirm(final Account account, final Jid to, final String id, final Jid counterpart, final boolean groupChat) { MessagePacket packet = new MessagePacket(); packet.setType(groupChat ? MessagePacket.TYPE_GROUPCHAT : MessagePacket.TYPE_CHAT); packet.setTo(groupChat ? to.toBareJid() : to); packet.setFrom(account.getJid()); - Element received = packet.addChild("displayed", "urn:xmpp:chat-markers:0"); - received.setAttribute("id", id); + Element displayed = packet.addChild("displayed", "urn:xmpp:chat-markers:0"); + displayed.setAttribute("id", id); + if (groupChat && counterpart != null) { + displayed.setAttribute("sender", counterpart.toPreppedString()); + } packet.addChild("store", "urn:xmpp:hints"); return packet; } diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index d5003dc11..f3be9651f 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -688,6 +688,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece Element displayed = packet.findChild("displayed", "urn:xmpp:chat-markers:0"); if (displayed != null) { final String id = displayed.getAttribute("id"); + final Jid sender = displayed.getAttributeAsJid("sender"); if (packet.fromAccount(account)) { Conversation conversation = mXmppConnectionService.find(account, counterpart.toBareJid()); if (conversation != null && (query == null || query.isCatchup())) { @@ -695,8 +696,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } } else if (isTypeGroupChat) { Conversation conversation = mXmppConnectionService.find(account, counterpart.toBareJid()); - if (conversation != null && id != null) { - Message message = conversation.findMessageWithRemoteId(id); + if (conversation != null && id != null && sender != null) { + Message message = conversation.findMessageWithRemoteId(id, sender); if (message != null) { if (conversation.getMucOptions().isSelf(counterpart)) { if (!message.isRead() && (query == null || query.isCatchup())) { //checking if message is unread fixes race conditions with reflections diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 75995edb9..55c2a6008 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1398,9 +1398,14 @@ public class XmppConnectionService extends Service { } } + boolean mucMessage = conversation.getMode() == Conversation.MODE_MULTI && message.getType() != Message.TYPE_PRIVATE; + if (mucMessage) { + message.setCounterpart(conversation.getMucOptions().getSelf().getFullJid()); + } + if (resend) { if (packet != null && addToConversation) { - if (account.getXmppConnection().getFeatures().sm() || (conversation.getMode() == Conversation.MODE_MULTI && message.getCounterpart().isBareJid())) { + if (account.getXmppConnection().getFeatures().sm() || mucMessage) { markMessage(message, Message.STATUS_UNSEND); } else { markMessage(message, Message.STATUS_SEND); @@ -3596,7 +3601,7 @@ public class XmppConnectionService extends Service { Account account = conversation.getAccount(); final Jid to = markable.getCounterpart(); final boolean groupChat = conversation.getMode() == Conversation.MODE_MULTI; - MessagePacket packet = mMessageGenerator.confirm(account, to, markable.getRemoteMsgId(), groupChat); + MessagePacket packet = mMessageGenerator.confirm(account, to, markable.getRemoteMsgId(), markable.getCounterpart(), groupChat); this.sendMessagePacket(conversation.getAccount(), packet); } } |