parse LMC 1.1
This commit is contained in:
parent
e395da18bf
commit
be4953b1e4
|
@ -116,6 +116,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;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package eu.siacs.conversations.entities;
|
|||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
@ -13,23 +12,19 @@ import org.json.JSONObject;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.crypto.OmemoSetting;
|
||||
import eu.siacs.conversations.crypto.PgpDecryptionService;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.persistance.DatabaseBackend;
|
||||
import eu.siacs.conversations.services.AvatarService;
|
||||
import eu.siacs.conversations.services.QuickConversationsService;
|
||||
import eu.siacs.conversations.utils.JidHelper;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.xmpp.InvalidJid;
|
||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||
import eu.siacs.conversations.xmpp.mam.MamReference;
|
||||
import rocks.xmpp.addr.Jid;
|
||||
|
@ -311,11 +306,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;
|
||||
|
|
|
@ -437,6 +437,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;
|
||||
}
|
||||
|
@ -732,6 +741,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;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue