From 48a66b74f11dc0526545b18bef65436d75d978e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 27 Jul 2023 17:39:14 -0400 Subject: [PATCH] fix tests --- public/openapi/components/schemas/Chats.yaml | 4 ++-- public/openapi/read/user/userslug/chats/roomid.yaml | 4 ++-- src/messaging/create.js | 1 + src/upgrades/3.3.0/chat_message_mids.js | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/openapi/components/schemas/Chats.yaml b/public/openapi/components/schemas/Chats.yaml index fe2ff9f73c..36404313ff 100644 --- a/public/openapi/components/schemas/Chats.yaml +++ b/public/openapi/components/schemas/Chats.yaml @@ -37,9 +37,9 @@ MessageObject: roomId: type: number deleted: - type: boolean + type: number system: - type: boolean + type: number edited: type: number timestampISO: diff --git a/public/openapi/read/user/userslug/chats/roomid.yaml b/public/openapi/read/user/userslug/chats/roomid.yaml index 025499b753..cb350aa2e0 100644 --- a/public/openapi/read/user/userslug/chats/roomid.yaml +++ b/public/openapi/read/user/userslug/chats/roomid.yaml @@ -59,9 +59,9 @@ get: roomId: type: string deleted: - type: boolean + type: number system: - type: boolean + type: number edited: type: number timestampISO: diff --git a/src/messaging/create.js b/src/messaging/create.js index 87ec24729f..872f22613f 100644 --- a/src/messaging/create.js +++ b/src/messaging/create.js @@ -67,6 +67,7 @@ module.exports = function (Messaging) { Messaging.addMessageToRoom(roomId, mid, timestamp), Messaging.markRead(uid, roomId), db.sortedSetAdd('messages:mid', timestamp, mid), + db.incrObjectField('global', 'messageCount'), ]; if (roomData.public) { tasks.push( diff --git a/src/upgrades/3.3.0/chat_message_mids.js b/src/upgrades/3.3.0/chat_message_mids.js index ebb79324fa..d7f349ae98 100644 --- a/src/upgrades/3.3.0/chat_message_mids.js +++ b/src/upgrades/3.3.0/chat_message_mids.js @@ -4,7 +4,6 @@ const db = require('../../database'); const batch = require('../../batch'); - module.exports = { name: 'Set mid on message objects and create messages:mid', timestamp: Date.UTC(2023, 6, 27), @@ -41,5 +40,7 @@ module.exports = { }, { batch: 500, }); + const count = await db.sortedSetCard(`messages:mid`); + await db.setObjectField('global', 'messageCount', count); }, };