@peopl-health/nexus 6.0.20 → 6.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -194,7 +194,8 @@ async function countMovedMessages(target, messages) {
194
194
  const counted = messages.filter((doc) => !INTERNAL_ORIGINS.has(doc.origin));
195
195
  if (!counted.length) return;
196
196
  const latest = await Message.findOne({ _id: { $in: counted.map((doc) => doc._id) } }, null, { sort: { createdAt: -1 } }).lean();
197
- await Thread.updateOne({ code: target }, { $inc: { messageCount: counted.length } });
197
+ const unread = counted.filter((doc) => !doc.from_me && doc.read !== true).length;
198
+ await Thread.updateOne({ code: target }, { $inc: { messageCount: counted.length, unreadCount: unread } });
198
199
  await Thread.updateOne(
199
200
  { code: target, $or: [{ lastMessageAt: null }, { lastMessageAt: { $lt: latest.createdAt } }] },
200
201
  { $set: threadPreview(latest, latest.createdAt) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "6.0.20",
3
+ "version": "6.0.21",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",