Add extensionless file name to /chats endpoints

69de212cc33dca8a58d2d4ec7e2a4b32fbe10fa7

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +5 -2Showing whitespace changes
src/endpoints/chats.js+5 -2
@@ -354,7 +354,8 @@ async function checkChatIntegrity(filePath, integritySlug) {
354354
355355/**
356356 * @typedef {Object} ChatInfo
357357 * @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)
358359 * @property {string} [file_size] - The size of the chat file
359360 * @property {number} [chat_items] - The number of chat items in the file
360361 * @property {string} [mes] - The last message in the chat
@@ -372,11 +373,13 @@ async function checkChatIntegrity(filePath, integritySlug) {
372373 */
373374export async function getChatInfo(pathToFile, additionalData = {}, isGroup = false, withMetadata = false) {
374375 return new Promise(async (res) => {
376+ const parsedPath = path.parse(pathToFile);
375377 const stats = await fs.promises.stat(pathToFile);
376378 const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`;
377379
378380 const chatData = {
379- file_name: path.parse(pathToFile).base,
381+ file_id: parsedPath.name,
382+ file_name: parsedPath.base,
380383 file_size: fileSizeInKB,
381384 chat_items: 0,
382385 mes: '[The chat is empty]',