Browse Source

make small fix with reply

unknown 2 years ago
parent
commit
e0e6b0353c
1 changed files with 3 additions and 3 deletions
  1. 3 3
      controllers/contacts.js

+ 3 - 3
controllers/contacts.js

@@ -96,7 +96,7 @@ const updateContact = async (req, res, next) => {
 	try {
 		const { id, _id, name, lastName, companionId } = req.body;
 		const userId = req.user.id;
-		const chat = await ChatModel.getByField(companionId, userId);
+		const userChat = await ChatModel.getByField(companionId, userId);
 		await ContactModel.update(id, userId, { name, lastName });
 		await ChatModel.update(_id, userId, { name, lastName });
 		await MessageModel.updateOwnerMessages(
@@ -106,8 +106,8 @@ const updateContact = async (req, res, next) => {
 		await MessageModel.updateOwnerMessages(
 			{
 				companionId,
-				replyName: { $eq: chat.name },
-				replyLastName: { $eq: chat.lastName },
+				replyName: { $eq: userChat.name },
+				replyLastName: { $eq: userChat.lastName },
 				owner: userId,
 			},
 			{ replyName: name, replyLastName: lastName }