aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-09-13 21:39:41 +0200
committerChristian Schneppe <christian@pix-art.de>2019-09-13 21:39:41 +0200
commit62209dc7acfd7a416382ae18dc6d0fad329ea400 (patch)
tree317287f702fe90997b6ead2e637151aa61c014a0 /src/main/java/de/pixart/messenger
parenteb34cdc3e350a50ce98959bbf05f83813a6c2e12 (diff)
parse LMC 1.1
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/Config.java2
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java5
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java17
-rw-r--r--src/main/java/de/pixart/messenger/generator/MessageGenerator.java3
4 files changed, 23 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java
index 96b588b32..13e1cc28b 100644
--- a/src/main/java/de/pixart/messenger/Config.java
+++ b/src/main/java/de/pixart/messenger/Config.java
@@ -133,6 +133,8 @@ public final class Config {
public static final boolean IGNORE_ID_REWRITE_IN_MUC = true;
public static final boolean MUC_LEAVE_BEFORE_JOIN = true;
+ public static final boolean USE_LMC_VERSION_1_1 = false;
+
public static final long MAM_MAX_CATCHUP = MILLISECONDS_IN_DAY * 5;
public static final int MAM_MAX_MESSAGES = 750;
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index a43899663..866b33597 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -365,11 +365,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
public Message findMessageWithRemoteIdAndCounterpart(String id, Jid counterpart, boolean received, boolean carbon) {
synchronized (this.messages) {
for (int i = this.messages.size() - 1; i >= 0; --i) {
- Message message = messages.get(i);
+ final Message message = messages.get(i);
if (counterpart.equals(message.getCounterpart())
&& ((message.getStatus() == Message.STATUS_RECEIVED) == received)
&& (carbon == message.isCarbon() || received)) {
- if (id.equals(message.getRemoteMsgId()) && !message.isFileOrImage() && !message.treatAsDownloadable()) {
+ final boolean idMatch = id.equals(message.getRemoteMsgId()) || message.remoteMsgIdMatchInEdit(id);
+ if (idMatch && !message.isFileOrImage() && !message.treatAsDownloadable()) {
return message;
} else {
return null;
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index 59047550b..c0e6fb8cb 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -451,6 +451,15 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
this.edits.add(new Edited(edited, serverMsgId));
}
+ public boolean remoteMsgIdMatchInEdit(String id) {
+ for (Edited edit : this.edits) {
+ if (id.equals(edit.getEditedId())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public String getBodyLanguage() {
return this.bodyLanguage;
}
@@ -751,6 +760,14 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
}
}
+ public String getEditedIdWireFormat() {
+ if (edits.size() > 0) {
+ return edits.get(Config.USE_LMC_VERSION_1_1 ? 0 : edits.size() - 1).getEditedId();
+ } else {
+ throw new IllegalStateException("Attempting to store unedited message");
+ }
+ }
+
public void setOob(boolean isOob) {
this.oob = isOob;
}
diff --git a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
index 7c1caae04..623c480ea 100644
--- a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java
@@ -14,7 +14,6 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage;
import de.pixart.messenger.entities.Account;
-import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.http.P1S3UrlStreamHandler;
@@ -63,7 +62,7 @@ public class MessageGenerator extends AbstractGenerator {
packet.setId(message.getUuid());
packet.addChild("origin-id", Namespace.STANZA_IDS).setAttribute("id", message.getUuid());
if (message.edited()) {
- packet.addChild("replace", "urn:xmpp:message-correct:0").setAttribute("id", message.getEditedId());
+ packet.addChild("replace", "urn:xmpp:message-correct:0").setAttribute("id", message.getEditedIdWireFormat());
}
return packet;
}