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
355/**355/**
356 * @typedef {Object} ChatInfo356 * @typedef {Object} ChatInfo
357 * @property {string} [file_name] - The name of the chat file357 * @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 file359 * @property {string} [file_size] - The size of the chat file
359 * @property {number} [chat_items] - The number of chat items in the file360 * @property {number} [chat_items] - The number of chat items in the file
360 * @property {string} [mes] - The last message in the chat361 * @property {string} [mes] - The last message in the chat
@@ -372,11 +373,13 @@ async function checkChatIntegrity(filePath, integritySlug) {
372 */373 */
373export async function getChatInfo(pathToFile, additionalData = {}, isGroup = false, withMetadata = false) {374export 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`;
377379
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]',