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)
throws DbException {
BdfDictionary query = BdfDictionary.of(
new BdfEntry(MSG_KEY_MSG_TYPE, PRIVATE_MESSAGE));
Map<MessageId, BdfDictionary> results;
try {
results =
clientHelper.getMessageMetadataAsDictionary(txn, g, query);
Map<MessageId, BdfDictionary> metadata =
clientHelper.getMessageMetadataAsDictionary(txn, g);
int msgCount = 0;
int unreadCount = 0;
for (Entry<MessageId, BdfDictionary> entry : metadata.entrySet()) {
BdfDictionary meta = entry.getValue();
Long messageType = meta.getOptionalLong(MSG_KEY_MSG_TYPE);
if (messageType == null || messageType == PRIVATE_MESSAGE) {
msgCount++;
if (!meta.getBoolean(MSG_KEY_READ)) unreadCount++;
}
}
messageTracker.resetGroupCount(txn, g, msgCount, unreadCount);
} catch (FormatException e) {
throw new DbException(e);
}
int msgCount = results.size();
int unreadCount = 0;
for (Entry<MessageId, BdfDictionary> entry : results.entrySet()) {
BdfDictionary meta = entry.getValue();
boolean read;
try {
read = meta.getBoolean(MSG_KEY_READ);
} catch (FormatException e) {
throw new DbException(e);
}
if (!read) unreadCount++;
}
messageTracker.resetGroupCount(txn, g, msgCount, unreadCount);
}
}