Include legacy messages when recalculating group count.

This commit is contained in:
akwizgran
2021-02-26 13:05:16 +00:00
committed by Torsten Grote
parent 1083507752
commit b56a9beb1d

View File

@@ -550,27 +550,22 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
private void recalculateGroupCount(Transaction txn, GroupId g) private void recalculateGroupCount(Transaction txn, GroupId g)
throws DbException { throws DbException {
BdfDictionary query = BdfDictionary.of(
new BdfEntry(MSG_KEY_MSG_TYPE, PRIVATE_MESSAGE));
Map<MessageId, BdfDictionary> results;
try { try {
results = Map<MessageId, BdfDictionary> metadata =
clientHelper.getMessageMetadataAsDictionary(txn, g, query); clientHelper.getMessageMetadataAsDictionary(txn, g);
} catch (FormatException e) { int msgCount = 0;
throw new DbException(e);
}
int msgCount = results.size();
int unreadCount = 0; int unreadCount = 0;
for (Entry<MessageId, BdfDictionary> entry : results.entrySet()) { for (Entry<MessageId, BdfDictionary> entry : metadata.entrySet()) {
BdfDictionary meta = entry.getValue(); BdfDictionary meta = entry.getValue();
boolean read; Long messageType = meta.getOptionalLong(MSG_KEY_MSG_TYPE);
try { if (messageType == null || messageType == PRIVATE_MESSAGE) {
read = meta.getBoolean(MSG_KEY_READ); msgCount++;
} catch (FormatException e) { if (!meta.getBoolean(MSG_KEY_READ)) unreadCount++;
throw new DbException(e);
} }
if (!read) unreadCount++;
} }
messageTracker.resetGroupCount(txn, g, msgCount, unreadCount); messageTracker.resetGroupCount(txn, g, msgCount, unreadCount);
} catch (FormatException e) {
throw new DbException(e);
}
} }
} }