Add extensionless file name to /chats endpoints
| @@ -354,7 +354,8 @@ async function checkChatIntegrity(filePath, integritySlug) { | ||
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * @typedef {Object} ChatInfo |
| 357 | 357 | * @property {string} [file_namefile_id] - The name of the chat file (without extension) |
| 358 | + * @property {string} [file_name] - The name of the chat file (with extension) | |
| 358 | 359 | * @property {string} [file_size] - The size of the chat file |
| 359 | 360 | * @property {number} [chat_items] - The number of chat items in the file |
| 360 | 361 | * @property {string} [mes] - The last message in the chat |
| @@ -372,11 +373,13 @@ async function checkChatIntegrity(filePath, integritySlug) { | ||
| 372 | 373 | */ |
| 373 | 374 | export async function getChatInfo(pathToFile, additionalData = {}, isGroup = false, withMetadata = false) { |
| 374 | 375 | return new Promise(async (res) => { |
| 376 | + const parsedPath = path.parse(pathToFile); | |
| 375 | 377 | const stats = await fs.promises.stat(pathToFile); |
| 376 | 378 | const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`; |
| 377 | 379 | |
| 378 | 380 | const chatData = { |
| 379 | - file_name: path.parse(pathToFile).base, | |
| 381 | + file_id: parsedPath.name, | |
| 382 | + file_name: parsedPath.base, | |
| 380 | 383 | file_size: fileSizeInKB, |
| 381 | 384 | chat_items: 0, |
| 382 | 385 | mes: '[The chat is empty]', |