Преглед на файлове

add deleted forward and reply

unknown преди 2 години
родител
ревизия
bfea3255cc
променени са 2 файла, в които са добавени 10 реда и са изтрити 24 реда
  1. 6 24
      controllers/messages.js
  2. 4 0
      model/schemas/message.js

+ 6 - 24
controllers/messages.js

@@ -74,6 +74,7 @@ const editMessage = async (req, res, next) => {
 			{
 				message: userMessage.fullType === null ? message : userMessage.message,
 				caption,
+				edited: true,
 			}
 		);
 
@@ -88,6 +89,7 @@ const editMessage = async (req, res, next) => {
 				replyMessage:
 					userMessage.fullType === null ? message : userMessage.replyMessage,
 				replyCaption: caption,
+				edited: true,
 			}
 		);
 		const isChat = await ChatModel.getByField(userMessage.companionId, userId);
@@ -202,17 +204,12 @@ const removeMessage = async (req, res, next) => {
 				oldId: userMessage._id,
 			},
 			{
+				deleted: true,
 				replyMessage: null,
-				replyName: null,
-				replyLastName: null,
 				replyCaption: null,
 				forwardMessage: null,
-				forwardMessage: null,
-				forwardName: null,
-				forwardLastName: null,
 				forwardCaption: null,
 				fullType: null,
-				companionIdForwardToAndFrom: null,
 				oldId: null,
 			}
 		);
@@ -226,17 +223,12 @@ const removeMessage = async (req, res, next) => {
 				oldId: companionMessage._id,
 			},
 			{
+				deleted: true,
 				replyMessage: null,
-				replyName: null,
-				replyLastName: null,
 				replyCaption: null,
 				forwardMessage: null,
-				forwardMessage: null,
-				forwardName: null,
-				forwardLastName: null,
 				forwardCaption: null,
 				fullType: null,
-				companionIdForwardToAndFrom: null,
 				oldId: null,
 			}
 		);
@@ -312,17 +304,12 @@ const removeSelected = async (req, res, next) => {
 					oldId: userMessage._id,
 				},
 				{
+					deleted: true,
 					replyMessage: null,
-					replyName: null,
-					replyLastName: null,
 					replyCaption: null,
 					forwardMessage: null,
-					forwardMessage: null,
-					forwardName: null,
-					forwardLastName: null,
 					forwardCaption: null,
 					fullType: null,
-					companionIdForwardToAndFrom: null,
 					oldId: null,
 				}
 			);
@@ -336,17 +323,12 @@ const removeSelected = async (req, res, next) => {
 					oldId: companionMessage._id,
 				},
 				{
+					deleted: true,
 					replyMessage: null,
-					replyName: null,
-					replyLastName: null,
 					replyCaption: null,
 					forwardMessage: null,
-					forwardMessage: null,
-					forwardName: null,
-					forwardLastName: null,
 					forwardCaption: null,
 					fullType: null,
-					companionIdForwardToAndFrom: null,
 					oldId: null,
 				}
 			);

+ 4 - 0
model/schemas/message.js

@@ -110,6 +110,10 @@ const messageSchema = new Schema(
 			type: Boolean,
 			default: false,
 		},
+		deleted: {
+			type: Boolean,
+			default: false,
+		},
 		owner: {
 			type: SchemaTypes.ObjectId,
 			ref: 'user',