feat: Add chat cache scan & clear to NTQQApi

This commit is contained in:
Misa Liu 2024-02-24 21:40:21 +08:00
parent c600c38a92
commit afe0ff89a7
No known key found for this signature in database
GPG Key ID: F70B23D0A4FED791
2 changed files with 68 additions and 2 deletions

View File

@ -15,7 +15,9 @@ import {
RawMessage,
SelfInfo,
SendMessageElement,
User
User,
ChatCacheList,
ChatCacheListItemBasic
} from "./types";
import * as fs from "fs";
import {addHistoryMsg, friendRequests, groupNotifies, msgHistory, selfInfo} from "../common/data";
@ -71,6 +73,17 @@ export enum NTQQApiMethod {
SET_MEMBER_ROLE = "nodeIKernelGroupService/modifyMemberRole",
PUBLISH_GROUP_BULLETIN = "nodeIKernelGroupService/publishGroupBulletinBulletin",
SET_GROUP_NAME = "nodeIKernelGroupService/modifyGroupName",
CACHE_SET_SILENCE = 'nodeIKernelStorageCleanService/setSilentScan',
CACHE_ADD_SCANNED_PATH = 'nodeIKernelStorageCleanService/addCacheScanedPaths', // TODO: Unused method
CACHE_PATH_HOT_UPDATE = 'getHotUpdateCachePath', // TODO: Unused method
CACHE_PATH_DESKTOP_TEMP = 'getDesktopTmpPath', // TODO: Unused method
CACHE_PATH_SESSION = 'getCleanableAppSessionPathList', // TODO: Unused method
CACHE_SCAN = 'nodeIKernelStorageCleanService/scanCache',
CACHE_CLEAR = '', // TODO
CACHE_CHAT_SCAN = 'nodeIKernelStorageCleanService/getChatCacheInfo',
CACHE_CHAT_CLEAR = 'nodeIKernelStorageCleanService/clearChatCacheInfo',
}
enum NTQQApiChannel {
@ -684,4 +697,38 @@ export class NTQQApi {
static publishGroupBulletin(groupQQ: string, title: string, content: string) {
}
static async setCacheSilentScan(isSilent: boolean = true) {
return await callNTQQApi({
methodName: NTQQApiMethod.CACHE_SET_SILENCE,
args: [{
isSilent
}, null]
});
}
static getChatCacheList(type: 1 | 2, pageSize: number = 80, pageIndex: number = 0) {
return new Promise<ChatCacheList>((res, rej) => {
callNTQQApi<ChatCacheList>({
methodName: NTQQApiMethod.CACHE_CHAT_SCAN,
args: [{
ChatType: type,
pageSize,
order: 1,
pageIndex
}, null]
}).then(list => res(list))
.catch(e => rej(e));
});
}
static async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: unknown[] = []) {
return await callNTQQApi<GeneralCallResult>({
methodName: NTQQApiMethod.CACHE_CHAT_CLEAR,
args: [{
chats,
fileKeys
}, null]
});
}
}

View File

@ -355,3 +355,22 @@ export interface FriendRequestNotify {
buddyReqs: FriendRequest[]
}
}
export interface ChatCacheList {
pageCount: number,
infos: ChatCacheListItem[]
}
export interface ChatCacheListItem {
chatType: 1 | 2,
basicChatCacheInfo: ChatCacheListItemBasic,
guildChatCacheInfo: unknown[] // TODO: 没用过频道所以不知道这里边的详细内容
}
export interface ChatCacheListItemBasic {
chatSize: string,
chatTime: string,
uid: string,
uin: string,
remarkName: string,
nickName: string
}