do not merge failed decryptions

fixes #4314
This commit is contained in:
Daniel Gultsch 2022-05-02 08:29:51 +02:00
parent cf4e979431
commit 85f06f1cd6
2 changed files with 9 additions and 3 deletions

View file

@ -14,6 +14,7 @@ import org.json.JSONException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -633,9 +634,8 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_PGP &&
message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED &&
this.getType() == message.getType() && this.getType() == message.getType() &&
//this.getStatus() == message.getStatus() &&
isStatusMergeable(this.getStatus(), message.getStatus()) && isStatusMergeable(this.getStatus(), message.getStatus()) &&
this.getEncryption() == message.getEncryption() && isEncryptionMergeable(this.getEncryption(),message.getEncryption()) &&
this.getCounterpart() != null && this.getCounterpart() != null &&
this.getCounterpart().equals(message.getCounterpart()) && this.getCounterpart().equals(message.getCounterpart()) &&
this.edited() == message.edited() && this.edited() == message.edited() &&
@ -668,6 +668,12 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
); );
} }
private static boolean isEncryptionMergeable(final int a, final int b) {
return a == b
&& Arrays.asList(ENCRYPTION_NONE, ENCRYPTION_DECRYPTED, ENCRYPTION_AXOLOTL)
.contains(a);
}
public void setCounterparts(List<MucOptions.User> counterparts) { public void setCounterparts(List<MucOptions.User> counterparts) {
this.counterparts = counterparts; this.counterparts = counterparts;
} }

View file

@ -4128,7 +4128,7 @@ public class XmppConnectionService extends Service {
} }
public void updateAccountUi() { public void updateAccountUi() {
for (OnAccountUpdate listener : threadSafeList(this.mOnAccountUpdates)) { for (final OnAccountUpdate listener : threadSafeList(this.mOnAccountUpdates)) {
listener.onAccountUpdate(); listener.onAccountUpdate();
} }
} }