Fix addressed to WFC count

This commit is contained in:
Bryan Ashby 2023-03-26 14:59:03 -06:00
parent 127d09a09b
commit cc20ffc85f
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
3 changed files with 16 additions and 6 deletions

View File

@ -519,8 +519,13 @@ function filterMessageListByReadACS(client, messageList) {
});
}
function getNewMessageCountInAreaForUser(userId, areaTag, cb) {
getMessageAreaLastReadId(userId, areaTag, (err, lastMessageId) => {
function getNewMessageCountInAreaForUser(
user,
areaTag,
options = { addrToOnly: false },
cb
) {
getMessageAreaLastReadId(user.userId, areaTag, (err, lastMessageId) => {
lastMessageId = lastMessageId || 0;
const filter = {
@ -530,7 +535,9 @@ function getNewMessageCountInAreaForUser(userId, areaTag, cb) {
};
if (Message.isPrivateAreaTag(areaTag)) {
filter.privateTagUserId = userId;
filter.privateTagUserId = user.userId;
} else if (options.addrToOnly) {
filter.toUserName = user.username;
}
Message.findMessages(filter, (err, count) => {
@ -554,8 +561,9 @@ function getNewMessageCountAddressedToUser(client, cb) {
getMessageAreaLastReadId(client.user.userId, areaTag, (_, lastMessageId) => {
lastMessageId = lastMessageId || 0; // eslint-disable-line no-unused-vars
getNewMessageCountInAreaForUser(
client.user.userId,
client.user,
areaTag,
{ addrToOnly: true },
(err, count) => {
newMessageCount += count;
return nextAreaTag(err);

View File

@ -157,8 +157,9 @@ exports.getModule = class NewScanModule extends MenuModule {
},
function getNewMessagesCountInArea(callback) {
msgArea.getNewMessageCountInAreaForUser(
self.client.user.userId,
self.client.user,
currentArea.areaTag,
{ addrToOnly: false },
(err, newMessageCount) => {
callback(err, newMessageCount);
}

View File

@ -461,8 +461,9 @@ class StatLog {
_refreshUserPrivateMailCount(client) {
const MsgArea = require('./message_area');
MsgArea.getNewMessageCountInAreaForUser(
client.user.userId,
client.user,
Message.WellKnownAreaTags.Private,
{ addrToOnly: false },
(err, count) => {
if (!err) {
client.user.setProperty(UserProps.NewPrivateMailCount, count);