diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Message.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java index dbcc05ab1..a90636e7f 100644 --- a/src/main/java/de/pixart/messenger/entities/Message.java +++ b/src/main/java/de/pixart/messenger/entities/Message.java @@ -99,7 +99,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable protected boolean file_deleted = false; protected boolean carbon = false; protected boolean oob = false; - protected List<Edited> edits = new ArrayList<>(); + protected List<Edit> edits = new ArrayList<>(); protected String relativeFilePath; protected boolean read = true; protected boolean deleted = false; @@ -181,7 +181,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable this.axolotlFingerprint = fingerprint; this.read = read; this.deleted = deleted; - this.edits = Edited.fromJson(edited); + this.edits = Edit.fromJson(edited); this.oob = oob; this.errorMessage = errorMessage; this.readByMarkers = readByMarkers == null ? new HashSet<>() : readByMarkers; @@ -272,7 +272,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable values.put(READ, read ? 1 : 0); values.put(DELETED, deleted ? 1 : 0); try { - values.put(EDITED, Edited.toJson(edits)); + values.put(EDITED, Edit.toJson(edits)); } catch (JSONException e) { Log.e(Config.LOGTAG, "error persisting json for edits", e); } @@ -453,11 +453,14 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable } public void putEdited(String edited, String serverMsgId) { - this.edits.add(new Edited(edited, serverMsgId)); + final Edit edit = new Edit(edited, serverMsgId); + if (this.edits.size() < 128 && !this.edits.contains(edit)) { + this.edits.add(edit); + } } - public boolean remoteMsgIdMatchInEdit(String id) { - for (Edited edit : this.edits) { + boolean remoteMsgIdMatchInEdit(String id) { + for(Edit edit : this.edits) { if (id.equals(edit.getEditedId())) { return true; } @@ -528,8 +531,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable boolean similar(Message message) { if (!isPrivateMessage() && this.serverMsgId != null && message.getServerMsgId() != null) { - return this.serverMsgId.equals(message.getServerMsgId()) || Edited.wasPreviouslyEditedServerMsgId(edits, message.getServerMsgId()); - } else if (Edited.wasPreviouslyEditedServerMsgId(edits, message.getServerMsgId())) { + return this.serverMsgId.equals(message.getServerMsgId()) || Edit.wasPreviouslyEditedServerMsgId(edits, message.getServerMsgId()); + } else if (Edit.wasPreviouslyEditedServerMsgId(edits, message.getServerMsgId())) { return true; } else if (this.body == null || this.counterpart == null) { return false; @@ -545,7 +548,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable final boolean matchingCounterpart = this.counterpart.equals(message.getCounterpart()); if (message.getRemoteMsgId() != null) { final boolean hasUuid = CryptoHelper.UUID_PATTERN.matcher(message.getRemoteMsgId()).matches(); - if (hasUuid && matchingCounterpart && Edited.wasPreviouslyEditedRemoteMsgId(edits, message.getRemoteMsgId())) { + if (hasUuid && matchingCounterpart && Edit.wasPreviouslyEditedRemoteMsgId(edits, message.getRemoteMsgId())) { return true; } return (message.getRemoteMsgId().equals(this.remoteMsgId) || message.getRemoteMsgId().equals(this.uuid)) |