From 91075e192b37ffca825b8d4c0b8b6b4dc435b5bc Mon Sep 17 00:00:00 2001 From: Misa Liu Date: Wed, 28 Feb 2024 00:04:55 +0800 Subject: [PATCH] feat: Add `getFileCacheInfo` to NTQQApi --- src/ntqqapi/ntcall.ts | 22 +++++++++++++++++++--- src/ntqqapi/types.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/ntqqapi/ntcall.ts b/src/ntqqapi/ntcall.ts index 81974d5..c8bc214 100644 --- a/src/ntqqapi/ntcall.ts +++ b/src/ntqqapi/ntcall.ts @@ -17,8 +17,8 @@ import { SendMessageElement, User, CacheScanResult, - ChatCacheList, - ChatCacheListItemBasic + ChatCacheList, ChatCacheListItemBasic, + CacheFileList, CacheFileListItem, CacheFileType, } from "./types"; import * as fs from "fs"; import {addHistoryMsg, friendRequests, groupNotifies, msgHistory, selfInfo} from "../common/data"; @@ -87,6 +87,7 @@ export enum NTQQApiMethod { CACHE_CLEAR = 'nodeIKernelStorageCleanService/clearCacheDataByKeys', CACHE_CHAT_GET = 'nodeIKernelStorageCleanService/getChatCacheInfo', + CACHE_FILE_GET = 'nodeIKernelStorageCleanService/getFileCacheInfo', CACHE_CHAT_CLEAR = 'nodeIKernelStorageCleanService/clearChatCacheInfo', } @@ -766,7 +767,7 @@ export class NTQQApi { }); } - static getChatCacheList(type: ChatType, pageSize: number = 80, pageIndex: number = 0) { + static getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) { return new Promise((res, rej) => { callNTQQApi({ methodName: NTQQApiMethod.CACHE_CHAT_GET, @@ -781,6 +782,21 @@ export class NTQQApi { }); } + static getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) { + const _lastRecord = lastRecord ? lastRecord : { fileType: fileType }; + + return callNTQQApi({ + methodName: NTQQApiMethod.CACHE_FILE_GET, + args: [{ + fileType: fileType, + restart: true, + pageSize: pageSize, + order: 1, + lastRecord: _lastRecord, + }, null] + }) + } + static async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: unknown[] = []) { return await callNTQQApi({ methodName: NTQQApiMethod.CACHE_CHAT_CLEAR, diff --git a/src/ntqqapi/types.ts b/src/ntqqapi/types.ts index 4b79e3d..53e1e22 100644 --- a/src/ntqqapi/types.ts +++ b/src/ntqqapi/types.ts @@ -392,3 +392,30 @@ export interface ChatCacheListItemBasic { chatType?: ChatType, isChecked?: boolean } + +export enum CacheFileType { + IMAGE = 0, + VIDEO = 1, + AUDIO = 2, + DOCUMENT = 3, + OTHER = 4, +} + +export interface CacheFileList { + infos: CacheFileListItem[], +} + +export interface CacheFileListItem { + fileSize: string, + fileTime: string, + fileKey: string, + elementId: string, + elementIdStr: string, + fileType: CacheFileType, + path: string, + fileName: string, + senderId: string, + previewPath: string, + senderName: string, + isChecked?: boolean, +}