refactor: GetFile

This commit is contained in:
手瓜一十雪
2024-08-28 23:45:33 +08:00
parent 36d656dc04
commit 0a51df8679
5 changed files with 81 additions and 33 deletions

View File

@@ -302,7 +302,18 @@ export class NTQQFileApi {
async downloadMediaByUuid() {
//napCatCore.session.getRichMediaService().downloadFileForFileUuid();
}
async downloadFileForModelId(peer: Peer, modelId: string, timeout = 1000 * 60 * 2) {
const [, fileTransNotifyInfo] = await this.core.eventWrapper.callNormalEventV2(
'NodeIKernelRichMediaService/downloadFileForModelId',
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
[peer, [modelId]],
() => true,
(arg) => arg?.commonFileInfo?.fileModelId === modelId,
1,
timeout,
);
return fileTransNotifyInfo.filePath;
}
async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) {
//logDebug('receive downloadMedia task', msgId, chatType, peerUid, elementId, thumbPath, sourcePath, timeout, force);
// 用于下载收到的消息中的图片等

View File

@@ -1,5 +1,25 @@
import { ChatType, RawMessage } from '@/core/entities';
export interface CommonFileInfo {
bizType: null;
chatType: number;
elemId: string;
favId: null;
fileModelId: string;
fileName: string;
fileSize: string;
md5: string;
md510m: string;
msgId: string;
msgTime: string;
parent: null;
peerUid: string;
picThumbPath: null;
sha: string;
sha3: string;
subId: string;
uuid: string;
[property: string]: any;
}
export interface OnRichMediaDownloadCompleteParams {
fileModelId: string,
msgElementId: string,
@@ -15,7 +35,7 @@ export interface OnRichMediaDownloadCompleteParams {
totalSize: string,
trasferStatus: number,
step: number,
commonFileInfo: unknown | null,
commonFileInfo?: CommonFileInfo,
fileSrvErrCode: string,
clientMsg: string,
businessId: number,

View File

@@ -155,7 +155,7 @@ export interface NodeIKernelRichMediaService {
}): unknown;
//arg3为“”
downloadFileForModelId(peer: Peer, ModelId: string[], arg3: string): unknown;
downloadFileForModelId(peer: Peer, ModelId: string[]): Promise<unknown>;
//第三个参数 Array<Type>
// this.fileId = "";