feat: send file api add name field

This commit is contained in:
linyuchen
2024-03-06 20:30:26 +08:00
parent 063b2460f8
commit 00c80bf181
9 changed files with 67 additions and 44 deletions

View File

@@ -81,19 +81,19 @@ export class SendMsgElementConstructor {
};
}
static async file(filePath: string, isVideo: boolean = false): Promise<SendFileElement> {
static async file(filePath: string, showPreview: boolean = false, fileName: string = ""): Promise<SendFileElement> {
let picHeight = 0;
let picWidth = 0;
if (isVideo) {
if (showPreview) {
picHeight = 1024;
picWidth = 768;
}
const {md5, fileName, path, fileSize} = await NTQQApi.uploadFile(filePath, ElementType.FILE);
const {md5, fileName: _fileName, path, fileSize} = await NTQQApi.uploadFile(filePath, ElementType.FILE);
let element: SendFileElement = {
elementType: ElementType.FILE,
elementId: "",
fileElement: {
fileName,
fileName: fileName || _fileName,
"filePath": path,
"fileSize": (fileSize).toString(),
picHeight,

View File

@@ -455,20 +455,19 @@ export class NTQQApi {
if (waitComplete) {
if ((await dbUtil.getMsgByLongId(sentMessage.msgId)).sendStatus == 2) {
return sentMessage
} else {
return await checkSendComplete()
}
}
// log(`给${peerUid}发送消息成功`)
return sentMessage
} else {
checkSendCompleteUsingTime += 500
if (checkSendCompleteUsingTime > timeout) {
throw ('发送超时')
else{
return sentMessage
}
await sleep(500)
return await checkSendComplete()
// log(`给${peerUid}发送消息成功`)
}
checkSendCompleteUsingTime += 500
if (checkSendCompleteUsingTime > timeout) {
throw ('发送超时')
}
await sleep(500)
return await checkSendComplete()
}
callNTQQApi({