unknown 2 лет назад
Родитель
Сommit
3880c148c4
100 измененных файлов с 122 добавлено и 16 удалено
  1. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1648731854880.mp3
  2. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1648731866397.mp3
  3. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649422367049.mp3
  4. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649853866536.mp3
  5. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649854692709.mp3
  6. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649932984438.mp3
  7. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947950610.mp3
  8. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947956771.mp3
  9. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947961987.mp3
  10. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947967424.mp3
  11. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947973175.mp3
  12. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947978549.mp3
  13. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947984476.mp3
  14. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947989722.mp3
  15. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649947995335.mp3
  16. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649948001346.mp3
  17. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649948007225.mp3
  18. BIN
      audios/62275dbc1f60894d30cce0c9/audioMessage1649948013054.mp3
  19. BIN
      audios/62275dbc1f60894d30cce0c9/song.mp3
  20. BIN
      audios/62275e151f60894d30cce0ca/audioMessage1649337587773.mp3
  21. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650014097175.mp3
  22. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650014100564.mp3
  23. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650014104433.mp3
  24. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650018755803.mp3
  25. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650018758422.mp3
  26. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650018761086.mp3
  27. BIN
      audios/62592cbbfaefbe27788786f6/audioMessage1650018763890.mp3
  28. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650369776170.mp3
  29. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650378661185.mp3
  30. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650378758552.mp3
  31. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650452296612.mp3
  32. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650453544010.mp3
  33. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650458115688.mp3
  34. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650626857393.mp3
  35. BIN
      audios/62595bc211a88f4dcc361a01/audioMessage1650632045105.mp3
  36. BIN
      audios/62595c1711a88f4dcc361a02/audioMessage1650459328074.mp3
  37. BIN
      audios/62595c1711a88f4dcc361a02/audioMessage1650636522592.mp3
  38. BIN
      audios/62595c1711a88f4dcc361a02/audioMessage1650984483016.mp3
  39. 45 8
      controllers/chats.js
  40. 2 2
      controllers/contacts.js
  41. 71 4
      controllers/messages.js
  42. 4 2
      controllers/user.js
  43. BIN
      files/62275dbc1f60894d30cce0c9/English File (4th ed) Upper-Intermediate - WB.pdf
  44. BIN
      files/62275dbc1f60894d30cce0c9/GrigoreCV.pdf
  45. BIN
      files/62275dbc1f60894d30cce0c9/React GUI Developer Cork, Ireland (1).docx
  46. BIN
      files/62275dbc1f60894d30cce0c9/React GUI Developer Cork, Ireland .docx
  47. BIN
      files/62275e151f60894d30cce0ca/English File (4th ed) Upper-Intermediate - WB.pdf
  48. BIN
      files/62275e151f60894d30cce0ca/GrigoreCvUa.pdf
  49. BIN
      files/62275e151f60894d30cce0ca/React GUI Developer Cork, Ireland (1).docx
  50. BIN
      files/62275e151f60894d30cce0ca/React GUI Developer Cork, Ireland .docx
  51. BIN
      files/62592cbbfaefbe27788786f6/GrigoreCV.pdf
  52. BIN
      files/62592cbbfaefbe27788786f6/React GUI Developer Cork, Ireland .docx
  53. BIN
      files/62595bc211a88f4dcc361a01/GrigoreCV.pdf
  54. BIN
      files/62595c1711a88f4dcc361a02/GrigoreCV.pdf
  55. BIN
      images/62038d25b235de73d8876e22/6-1.png
  56. BIN
      images/62038e77b235de73d8876e23/6-1.png
  57. BIN
      images/620390a010645820b462512c/6-3.png
  58. BIN
      images/6203933cb578256c8ca8d7dc/6-2.png
  59. BIN
      images/620394bfb578256c8ca8d7de/6-1.png
  60. BIN
      images/6203fda73c9f0010707a990f/6-3.png
  61. BIN
      images/6203fe5f3c9f0010707a9910/9M6INAgU.png
  62. BIN
      images/6204014f3c9f0010707a9911/6-1.png
  63. BIN
      images/62042e66a31d1873e8c8d4e3/6-3.png
  64. BIN
      images/6204ddabad4c847040122033/изображение_viber_2021-01-02_13-51-35.jpg
  65. BIN
      images/620944de961e3b286057cf8b/6-1.png
  66. BIN
      images/6213605caf94c83914c70056/clipart289625.png
  67. BIN
      images/62136a16c07bc339f8a8dde4/clipart289625.png
  68. BIN
      images/62138202be322341e880f30a/telegram.png
  69. BIN
      images/6213822abe322341e880f30b/telegram.png
  70. BIN
      images/62138409d5f2ae2a5076e0fb/clipart289625.png
  71. BIN
      images/6213843cd5f2ae2a5076e0fc/telegram.png
  72. BIN
      images/6213848cd5f2ae2a5076e0fd/telegram.png
  73. BIN
      images/6214c3f21784bb3a843aacc9/clipart289625.png
  74. BIN
      images/6214c4381784bb3a843aacca/telegram.png
  75. BIN
      images/6214ddc1344fef42a89f0761/monkey.png
  76. BIN
      images/62151cee9936e92efc688793/qrcode_telegram.png
  77. BIN
      images/62273c1ceff0054430e7fa67/monkey.png
  78. BIN
      images/622759a73cd51752d44043a7/monkey.png
  79. BIN
      images/62275a0b3cd51752d44043a8/telegram.png
  80. BIN
      images/62275dbc1f60894d30cce0c9/NicePng_face-clipart-png_3622337(1).png
  81. BIN
      images/62275dbc1f60894d30cce0c9/clipart289625.png
  82. BIN
      images/62275dbc1f60894d30cce0c9/download (1).jpg
  83. BIN
      images/62275dbc1f60894d30cce0c9/download(2).png
  84. BIN
      images/62275dbc1f60894d30cce0c9/download.jpg
  85. BIN
      images/62275dbc1f60894d30cce0c9/download.png
  86. BIN
      images/62275dbc1f60894d30cce0c9/driveLicense.jpg
  87. BIN
      images/62275dbc1f60894d30cce0c9/id.jpg
  88. BIN
      images/62275dbc1f60894d30cce0c9/monkey.png
  89. BIN
      images/62275dbc1f60894d30cce0c9/nature-g0393aaedf_1920.jpg
  90. BIN
      images/62275dbc1f60894d30cce0c9/passport.jpg
  91. BIN
      images/62275dbc1f60894d30cce0c9/qrcode_telegram.png
  92. BIN
      images/62275dbc1f60894d30cce0c9/telegram.png
  93. BIN
      images/62275dbc1f60894d30cce0c9/videoPoster.png
  94. BIN
      images/62275dbc1f60894d30cce0c9/путин.jpeg
  95. BIN
      images/62275e151f60894d30cce0ca/download (1).jpg
  96. BIN
      images/62275e151f60894d30cce0ca/monkey.png
  97. BIN
      images/62275e151f60894d30cce0ca/telegram.png
  98. BIN
      images/62275e151f60894d30cce0ca/videoPoster.png
  99. BIN
      images/62275e151f60894d30cce0ca/путин.jpeg
  100. 0 0
      images/622b46a456535b47e86da8d5/clipart289625.png

BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1648731854880.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1648731866397.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649422367049.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649853866536.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649854692709.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649932984438.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947950610.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947956771.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947961987.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947967424.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947973175.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947978549.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947984476.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947989722.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649947995335.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649948001346.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649948007225.mp3


BIN
audios/62275dbc1f60894d30cce0c9/audioMessage1649948013054.mp3


BIN
audios/62275dbc1f60894d30cce0c9/song.mp3


BIN
audios/62275e151f60894d30cce0ca/audioMessage1649337587773.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650014097175.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650014100564.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650014104433.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650018755803.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650018758422.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650018761086.mp3


BIN
audios/62592cbbfaefbe27788786f6/audioMessage1650018763890.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650369776170.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650378661185.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650378758552.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650452296612.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650453544010.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650458115688.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650626857393.mp3


BIN
audios/62595bc211a88f4dcc361a01/audioMessage1650632045105.mp3


BIN
audios/62595c1711a88f4dcc361a02/audioMessage1650459328074.mp3


BIN
audios/62595c1711a88f4dcc361a02/audioMessage1650636522592.mp3


BIN
audios/62595c1711a88f4dcc361a02/audioMessage1650984483016.mp3


+ 45 - 8
controllers/chats.js

@@ -1,6 +1,9 @@
 const ChatModel = require('../model/chat');
 const UserModel = require('../model/user');
 const MessageModel = require('../model/message');
+const fs = require('fs').promises;
+const path = require('path');
+require('dotenv').config();
 
 const listChats = async (req, res, next) => {
 	try {
@@ -38,6 +41,7 @@ const startChat = async (req, res, next) => {
 			originalName,
 			originalLastName,
 			avatarUrl,
+			avatarsArr,
 			color,
 			online,
 			number,
@@ -48,6 +52,7 @@ const startChat = async (req, res, next) => {
 			originalName: OriginalName,
 			originalLastName: OriginalLastName,
 			avatarUrl: AvatarUrl,
+			avatarsArr: AvatarsArr,
 			color: Color,
 			online: Online,
 			number: Number,
@@ -57,6 +62,7 @@ const startChat = async (req, res, next) => {
 				originalName,
 				originalLastName,
 				avatarUrl,
+				avatarsArr,
 				color,
 				online,
 				number,
@@ -65,6 +71,7 @@ const startChat = async (req, res, next) => {
 				originalName: OriginalName,
 				originalLastName: OriginalLastName,
 				avatarUrl: AvatarUrl,
+				avatarsArr: AvatarsArr,
 				color: Color,
 				online: Online,
 				number: Number,
@@ -84,6 +91,7 @@ const startChat = async (req, res, next) => {
 				originalName,
 				originalLastName,
 				avatarUrl,
+				avatarsArr,
 				color,
 				online,
 				number,
@@ -96,6 +104,7 @@ const startChat = async (req, res, next) => {
 				originalName: OriginalName,
 				originalLastName: originalLastName,
 				avatarUrl: AvatarUrl,
+				avatarsArr: AvatarsArr,
 				color: Color,
 				online: Online,
 				number: Number,
@@ -117,14 +126,42 @@ const removeChatForBoth = async (req, res, next) => {
 	try {
 		const companionId = req.params.id;
 		const userId = req.user.id;
+		const DIR_IMAGES = process.env.DIR_IMAGES;
+		const DIR_AUDIOS = process.env.DIR_AUDIOS;
+		const DIR_VIDEOS = process.env.DIR_VIDEOS;
+		const DIR_FILES = process.env.DIR_FILES;
 		const isUserChat = await ChatModel.getByField(companionId, userId);
 		const isCompanionChat = await ChatModel.getByField(userId, companionId);
-		if (isUserChat || isCompanionChat) {
-			isUserChat && (await MessageModel.removeAll(companionId, userId));
-			isCompanionChat && (await MessageModel.removeAll(userId, companionId));
-			isUserChat && (await ChatModel.remove(isUserChat._id, userId));
-			isCompanionChat &&
-				(await ChatModel.remove(isCompanionChat._id, companionId));
+		if (isUserChat && isCompanionChat) {
+			const deleteFile = async (type, message) => {
+				if (type !== 'text') {
+					switch (type) {
+						case 'image':
+							await fs.unlink(path.join(DIR_IMAGES, message));
+							break;
+						case 'audio':
+							await fs.unlink(path.join(DIR_AUDIOS, message));
+							break;
+						case 'video':
+							await fs.unlink(path.join(DIR_VIDEOS, message));
+							break;
+						default:
+							await fs.unlink(path.join(DIR_FILES, message));
+							break;
+					}
+				}
+			};
+			const { messages } = await MessageModel.getList(
+				{ owner: userId, companionId },
+				{}
+			);
+			await messages.forEach(
+				async ({ type, message }) => await deleteFile(type, message)
+			);
+			await MessageModel.removeAll(companionId, userId);
+			await MessageModel.removeAll(userId, companionId);
+			await ChatModel.remove(isUserChat._id, userId);
+			await ChatModel.remove(isCompanionChat._id, companionId);
 			return res.json({
 				status: 'success',
 				code: 200,
@@ -226,7 +263,7 @@ const typingChat = async (req, res, next) => {
 	}
 };
 
-const chatById = async (req, res, next) => {
+const getChatById = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
 		const companionId = req.params.companionId;
@@ -253,5 +290,5 @@ module.exports = {
 	sortChat,
 	seenChat,
 	typingChat,
-	chatById,
+	getChatById,
 };

+ 2 - 2
controllers/contacts.js

@@ -5,7 +5,7 @@ const ChatModel = require('../model/chat');
 const listContacts = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
-		const contacts = await ContactModel.getList(userId, req.query);
+		const contacts = await ContactModel.getList({ owner: userId }, req.query);
 		return res.json({
 			status: 'success',
 			code: 200,
@@ -47,7 +47,7 @@ const addContact = async (req, res, next) => {
 		const number = req.body.number;
 		const user = await UserModel.findByNumber(number);
 		const isExist = await ContactModel.getByField(number, userId);
-		if (user && !isExist) {
+		if (user && user.number !== number && !isExist) {
 			const { name, lastName, country, avatarUrl, color, _id } = user;
 			const newContact = await ContactModel.add({
 				companionId: _id,

+ 71 - 4
controllers/messages.js

@@ -21,6 +21,54 @@ const listMessages = async (req, res, next) => {
 	}
 };
 
+const removeMessage = async (req, res, next) => {
+	try {
+		const id = req.params.id;
+		const userId = req.user.id;
+		const DIR_IMAGES = process.env.DIR_IMAGES;
+		const DIR_AUDIOS = process.env.DIR_AUDIOS;
+		const DIR_VIDEOS = process.env.DIR_VIDEOS;
+		const DIR_FILES = process.env.DIR_FILES;
+		const userMessage = await MessageModel.remove(id, userId);
+		const companionMessage = await MessageModel.removeByFields(
+			userId,
+			userMessage.idTime,
+			userMessage.companionId
+		);
+		if (userMessage.type !== 'text') {
+			switch (userMessage.type) {
+				case 'image':
+					await fs.unlink(path.join(DIR_IMAGES, userMessage.message));
+					break;
+				case 'audio':
+					await fs.unlink(path.join(DIR_AUDIOS, userMessage.message));
+					break;
+				case 'video':
+					await fs.unlink(path.join(DIR_VIDEOS, userMessage.message));
+					break;
+				default:
+					await fs.unlink(path.join(DIR_FILES, userMessage.message));
+					break;
+			}
+		}
+		if (userMessage && companionMessage) {
+			return res.json({
+				status: 'success',
+				code: 200,
+				data: {},
+			});
+		} else {
+			return res.status(404).json({
+				status: 'error',
+				code: 404,
+				data: 'Not Found',
+			});
+		}
+	} catch (e) {
+		next(e);
+	}
+};
+
 const listMessagesById = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
@@ -42,6 +90,7 @@ const listMessagesById = async (req, res, next) => {
 const sentMessage = async (req, res, next) => {
 	try {
 		const { id, message } = req.body;
+		const idTime = Math.round(Date.now() / 1000);
 		const user = req.user;
 		const userId = user.id;
 		const companion = await UserModel.findById(id);
@@ -58,6 +107,7 @@ const sentMessage = async (req, res, next) => {
 				color,
 				number,
 				type: 'text',
+				idTime,
 				companionId: id,
 				owner: userId,
 			});
@@ -69,6 +119,7 @@ const sentMessage = async (req, res, next) => {
 				color,
 				number,
 				type: 'text',
+				idTime,
 				companionId: userId,
 				owner: id,
 			});
@@ -107,11 +158,13 @@ const imageMessage = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
 		const id = req.params.companionId;
+		const idTime = Math.round(Date.now() / 1000);
 		const isChat = await ChatModel.getByField(id, userId);
 		const isCompanionChat = await ChatModel.getByField(userId, id);
 		const DIR_IMAGES = process.env.DIR_IMAGES;
 		const pathToFile = req.file.path;
-		const newNameImg = req.file.originalname;
+		const originalName = req.file.originalname;
+		const newNameImg = `${Math.round(Date.now() / 1000)}${originalName}`;
 		const fullType = req.file.mimetype;
 		await Jimp.read(pathToFile);
 		await createFolderIsExist(path.join(DIR_IMAGES, userId));
@@ -128,6 +181,7 @@ const imageMessage = async (req, res, next) => {
 				number,
 				type: 'image',
 				fullType,
+				idTime,
 				companionId: id,
 				owner: userId,
 			});
@@ -140,6 +194,7 @@ const imageMessage = async (req, res, next) => {
 				number,
 				type: 'image',
 				fullType,
+				idTime,
 				companionId: userId,
 				owner: id,
 			});
@@ -178,11 +233,13 @@ const audioMessage = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
 		const id = req.params.companionId;
+		const idTime = Math.round(Date.now() / 1000);
 		const isChat = await ChatModel.getByField(id, userId);
 		const isCompanionChat = await ChatModel.getByField(userId, id);
 		const DIR_AUDIOS = process.env.DIR_AUDIOS;
 		const pathToFile = req.file.path;
-		const newNameAudio = req.file.originalname;
+		const originalName = req.file.originalname;
+		const newNameAudio = `${Math.round(Date.now() / 1000)}${originalName}`;
 		const fullType = req.file.mimetype;
 		await createFolderIsExist(path.join(DIR_AUDIOS, userId));
 		await fs.rename(pathToFile, path.join(DIR_AUDIOS, userId, newNameAudio));
@@ -198,6 +255,7 @@ const audioMessage = async (req, res, next) => {
 				number,
 				type: 'audio',
 				fullType,
+				idTime,
 				companionId: id,
 				owner: userId,
 			});
@@ -210,6 +268,7 @@ const audioMessage = async (req, res, next) => {
 				number,
 				type: 'audio',
 				fullType,
+				idTime,
 				companionId: userId,
 				owner: id,
 			});
@@ -248,11 +307,13 @@ const videoMessage = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
 		const id = req.params.companionId;
+		const idTime = Math.round(Date.now() / 1000);
 		const isChat = await ChatModel.getByField(id, userId);
 		const isCompanionChat = await ChatModel.getByField(userId, id);
 		const DIR_VIDEOS = process.env.DIR_VIDEOS;
 		const pathToFile = req.file.path;
-		const newNameVideo = req.file.originalname;
+		const originalName = req.file.originalname;
+		const newNameVideo = `${Math.round(Date.now() / 1000)}${originalName}`;
 		const fullType = req.file.mimetype;
 		await createFolderIsExist(path.join(DIR_VIDEOS, userId));
 		await fs.rename(pathToFile, path.join(DIR_VIDEOS, userId, newNameVideo));
@@ -268,6 +329,7 @@ const videoMessage = async (req, res, next) => {
 				number,
 				type: 'video',
 				fullType,
+				idTime,
 				companionId: id,
 				owner: userId,
 			});
@@ -280,6 +342,7 @@ const videoMessage = async (req, res, next) => {
 				number,
 				type: 'video',
 				fullType,
+				idTime,
 				companionId: userId,
 				owner: id,
 			});
@@ -318,11 +381,11 @@ const fileMessage = async (req, res, next) => {
 	try {
 		const userId = req.user.id;
 		const id = req.params.companionId;
+		const idTime = Math.round(Date.now() / 1000);
 		const isChat = await ChatModel.getByField(id, userId);
 		const isCompanionChat = await ChatModel.getByField(userId, id);
 		const DIR_FILES = process.env.DIR_FILES;
 		const pathToFile = req.file.path;
-		const newNameFile = req.file.originalname;
 		const fullType = req.file.mimetype;
 		let type;
 		switch (fullType) {
@@ -338,6 +401,7 @@ const fileMessage = async (req, res, next) => {
 			default:
 				break;
 		}
+		const newNameFile = `${Math.round(Date.now() / 1000)}file.${type}`;
 		await createFolderIsExist(path.join(DIR_FILES, userId));
 		await fs.rename(pathToFile, path.join(DIR_FILES, userId, newNameFile));
 		const fileUrl = path.normalize(path.join(userId, newNameFile));
@@ -352,6 +416,7 @@ const fileMessage = async (req, res, next) => {
 				number,
 				type,
 				fullType,
+				idTime,
 				companionId: id,
 				owner: userId,
 			});
@@ -364,6 +429,7 @@ const fileMessage = async (req, res, next) => {
 				number,
 				type,
 				fullType,
+				idTime,
 				companionId: userId,
 				owner: id,
 			});
@@ -400,6 +466,7 @@ const fileMessage = async (req, res, next) => {
 
 module.exports = {
 	listMessages,
+	removeMessage,
 	listMessagesById,
 	sentMessage,
 	imageMessage,

+ 4 - 2
controllers/user.js

@@ -151,7 +151,8 @@ const updateAvatar = async (req, res, next) => {
 		const token = req.user.token;
 		const DIR_IMAGES = process.env.DIR_IMAGES;
 		const pathToFile = req.file.path;
-		const newNameAvatar = req.file.originalname;
+		const originalName = req.file.originalname;
+		const newNameAvatar = `${Math.round(Date.now() / 1000)}${originalName}`;
 		const img = await Jimp.read(pathToFile);
 		await img
 			.autocrop()
@@ -164,7 +165,8 @@ const updateAvatar = async (req, res, next) => {
 		await createFolderIsExist(path.join(DIR_IMAGES, userId));
 		await fs.rename(pathToFile, path.join(DIR_IMAGES, userId, newNameAvatar));
 		const avatarUrl = path.normalize(path.join(userId, newNameAvatar));
-		await UserModel.updateUser(userId, { avatarUrl });
+		const avatarsArr = [avatarUrl, ...req.user.avatarsArr];
+		await UserModel.updateUser(userId, { avatarUrl, avatarsArr });
 		return res.status(200).json({
 			status: 'success',
 			code: 200,

BIN
files/62275dbc1f60894d30cce0c9/English File (4th ed) Upper-Intermediate - WB.pdf


BIN
files/62275dbc1f60894d30cce0c9/GrigoreCV.pdf


BIN
files/62275dbc1f60894d30cce0c9/React GUI Developer Cork, Ireland (1).docx


BIN
files/62275dbc1f60894d30cce0c9/React GUI Developer Cork, Ireland .docx


BIN
files/62275e151f60894d30cce0ca/English File (4th ed) Upper-Intermediate - WB.pdf


BIN
files/62275e151f60894d30cce0ca/GrigoreCvUa.pdf


BIN
files/62275e151f60894d30cce0ca/React GUI Developer Cork, Ireland (1).docx


BIN
files/62275e151f60894d30cce0ca/React GUI Developer Cork, Ireland .docx


BIN
files/62592cbbfaefbe27788786f6/GrigoreCV.pdf


BIN
files/62592cbbfaefbe27788786f6/React GUI Developer Cork, Ireland .docx


BIN
files/62595bc211a88f4dcc361a01/GrigoreCV.pdf


BIN
files/62595c1711a88f4dcc361a02/GrigoreCV.pdf


BIN
images/62038d25b235de73d8876e22/6-1.png


BIN
images/62038e77b235de73d8876e23/6-1.png


BIN
images/620390a010645820b462512c/6-3.png


BIN
images/6203933cb578256c8ca8d7dc/6-2.png


BIN
images/620394bfb578256c8ca8d7de/6-1.png


BIN
images/6203fda73c9f0010707a990f/6-3.png


BIN
images/6203fe5f3c9f0010707a9910/9M6INAgU.png


BIN
images/6204014f3c9f0010707a9911/6-1.png


BIN
images/62042e66a31d1873e8c8d4e3/6-3.png


BIN
images/6204ddabad4c847040122033/изображение_viber_2021-01-02_13-51-35.jpg


BIN
images/620944de961e3b286057cf8b/6-1.png


BIN
images/6213605caf94c83914c70056/clipart289625.png


BIN
images/62136a16c07bc339f8a8dde4/clipart289625.png


BIN
images/62138202be322341e880f30a/telegram.png


BIN
images/6213822abe322341e880f30b/telegram.png


BIN
images/62138409d5f2ae2a5076e0fb/clipart289625.png


BIN
images/6213843cd5f2ae2a5076e0fc/telegram.png


BIN
images/6213848cd5f2ae2a5076e0fd/telegram.png


BIN
images/6214c3f21784bb3a843aacc9/clipart289625.png


BIN
images/6214c4381784bb3a843aacca/telegram.png


BIN
images/6214ddc1344fef42a89f0761/monkey.png


BIN
images/62151cee9936e92efc688793/qrcode_telegram.png


BIN
images/62273c1ceff0054430e7fa67/monkey.png


BIN
images/622759a73cd51752d44043a7/monkey.png


BIN
images/62275a0b3cd51752d44043a8/telegram.png


BIN
images/62275dbc1f60894d30cce0c9/NicePng_face-clipart-png_3622337(1).png


BIN
images/62275dbc1f60894d30cce0c9/clipart289625.png


BIN
images/62275dbc1f60894d30cce0c9/download (1).jpg


BIN
images/62275dbc1f60894d30cce0c9/download(2).png


BIN
images/62275dbc1f60894d30cce0c9/download.jpg


BIN
images/62275dbc1f60894d30cce0c9/download.png


BIN
images/62275dbc1f60894d30cce0c9/driveLicense.jpg


BIN
images/62275dbc1f60894d30cce0c9/id.jpg


BIN
images/62275dbc1f60894d30cce0c9/monkey.png


BIN
images/62275dbc1f60894d30cce0c9/nature-g0393aaedf_1920.jpg


BIN
images/62275dbc1f60894d30cce0c9/passport.jpg


BIN
images/62275dbc1f60894d30cce0c9/qrcode_telegram.png


BIN
images/62275dbc1f60894d30cce0c9/telegram.png


BIN
images/62275dbc1f60894d30cce0c9/videoPoster.png


BIN
images/62275dbc1f60894d30cce0c9/путин.jpeg


BIN
images/62275e151f60894d30cce0ca/download (1).jpg


BIN
images/62275e151f60894d30cce0ca/monkey.png


BIN
images/62275e151f60894d30cce0ca/telegram.png


BIN
images/62275e151f60894d30cce0ca/videoPoster.png


BIN
images/62275e151f60894d30cce0ca/путин.jpeg


+ 0 - 0
images/622b46a456535b47e86da8d5/clipart289625.png


Некоторые файлы не были показаны из-за большого количества измененных файлов