Browse Source

work on unread messages

unknown 1 year ago
parent
commit
e51272ea4c
2 changed files with 8 additions and 1 deletions
  1. 4 1
      controllers/chats.js
  2. 4 0
      model/schemas/chat.js

+ 4 - 1
controllers/chats.js

@@ -205,7 +205,10 @@ const seenChat = async (req, res, next) => {
 				seen: total,
 				watched: false,
 			});
-			await ChatModel.update(isCompanionChat._id, id, { watched: true });
+			await ChatModel.update(isCompanionChat._id, id, {
+				watched: true,
+				seenCompanion: total,
+			});
 			return res.status(200).json({
 				status: 'success',
 				code: 200,

+ 4 - 0
model/schemas/chat.js

@@ -58,6 +58,10 @@ const chatSchema = new Schema(
 			type: Number,
 			default: 0,
 		},
+		seenCompanion: {
+			type: Number,
+			default: 0,
+		},
 		sort: {
 			type: Boolean,
 			default: false,