From 3a55e46fa17801719048cbc07787caf4a5436510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B3pez=20Guimaraes?= Date: Sat, 1 Nov 2025 12:11:14 +0000 Subject: [PATCH] fix(npfl): Query files from FileCTR Also use proper size on content size column. --- src/database.ts | 12 ++++++------ src/services/npfl.ts | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/database.ts b/src/database.ts index 55b3b31..e7bf865 100644 --- a/src/database.ts +++ b/src/database.ts @@ -130,10 +130,10 @@ export function getWUPTaskFiles(allowDeleted: boolean, bossAppID: string, taskID return FileWUP.find(filter); } -export function getCTRTaskFilesWithAttributes(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string, attribute1?: string, attribute2?: string, attribute3?: string): Promise { +export function getCTRTaskFilesWithAttributes(allowDeleted: boolean, bossAppID: string, taskID: string, country?: string, language?: string, attribute1?: string, attribute2?: string, attribute3?: string): Promise { verifyConnected(); - const filter: mongoose.FilterQuery = { + const filter: mongoose.FilterQuery = { task_id: taskID.slice(0, 7), boss_app_id: bossAppID, $and: [] @@ -162,22 +162,22 @@ export function getCTRTaskFilesWithAttributes(allowDeleted: boolean, bossAppID: } if (attribute1) { - filter.attribute1 = attribute1; + filter.attributes.attribute1 = attribute1; } if (attribute2) { - filter.attribute2 = attribute2; + filter.attributes.attribute2 = attribute2; } if (attribute3) { - filter.attribute3 = attribute3; + filter.attributes.attribute3 = attribute3; } if (filter.$and?.length === 0) { delete filter.$and; } - return FileWUP.find(filter); + return FileCTR.find(filter); } export function getCTRTaskFile(bossAppID: string, taskID: string, name: string, country?: string, language?: string): Promise { diff --git a/src/services/npfl.ts b/src/services/npfl.ts index ece6132..327bf3f 100644 --- a/src/services/npfl.ts +++ b/src/services/npfl.ts @@ -55,11 +55,11 @@ npfl.get('/p01/filelist/:appID/:taskID', async (request: express.Request<{ // * File lines have the following fields: // * // * - File name - // * - Unknown (password?) + // * - Description // * - Attribute 1 // * - Attribute 2 // * - Attribute 3 - // * - File size (0 is allowed) + // * - Content size (size of the first payload content) // * - Updated time (seconds) // * // * All fields of a file line are separated by a tab (\t) and are present even if no value. @@ -83,11 +83,11 @@ npfl.get('/p01/filelist/:appID/:taskID', async (request: express.Request<{ for (const file of files) { const params = [ file.name, - file.password, // * Unsure if this is really what this is for. Team Kirby Clash Deluxe uses this for passwords though - file.attribute1, - file.attribute2, - file.attribute3, - file.size, + file.attributes.description, + file.attributes.attribute1, + file.attributes.attribute2, + file.attributes.attribute3, + file.payload_contents[0]?.size ?? 0, file.updated / 1000n // * Expects time as seconds, not milliseconds ]; const line = `${params.join('\t')}\r\n`;