Keep MailboxUpdate immutable

This commit is contained in:
Daniel Lublin
2022-05-18 12:50:50 +02:00
parent 601ff50294
commit 7e215e7f84
3 changed files with 23 additions and 12 deletions

View File

@@ -87,9 +87,16 @@ class MailboxUpdateManagerImpl implements MailboxUpdateManager,
for (Contact c : db.getContacts(txn)) {
MailboxUpdate latest = getLocalUpdate(txn, c.getId());
if (!latest.getClientSupports().equals(CLIENT_SUPPORTS)) {
latest.setClientSupports(CLIENT_SUPPORTS);
MailboxUpdate updated;
if (latest.hasMailbox()) {
updated = new MailboxUpdateWithMailbox(
(MailboxUpdateWithMailbox) latest,
CLIENT_SUPPORTS);
} else {
updated = new MailboxUpdate(CLIENT_SUPPORTS);
}
Group g = getContactGroup(c);
storeMessageReplaceLatest(txn, g.getId(), latest);
storeMessageReplaceLatest(txn, g.getId(), updated);
}
}
return;