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