From b83c41ad56e0c15f885f7d93a777f48eebbd15c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 5 Sep 2024 14:55:11 +0800 Subject: [PATCH] fix: #339 --- manifest.json | 2 +- package.json | 2 +- src/common/version.ts | 2 +- src/core/apis/file.ts | 59 ------------------------------------- src/onebot/api/msg.ts | 61 +++------------------------------------ src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 7 files changed, 9 insertions(+), 121 deletions(-) diff --git a/manifest.json b/manifest.json index 8d322fc5..72379365 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.3.0", + "version": "2.3.2", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 6f3fe493..0383d3a8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.3.1", + "version": "2.3.2", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", diff --git a/src/common/version.ts b/src/common/version.ts index c849f8ee..542c094a 100644 --- a/src/common/version.ts +++ b/src/common/version.ts @@ -1 +1 @@ -export const napCatVersion = '2.3.0'; +export const napCatVersion = '2.3.2'; diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index 55fce983..2d1e7f05 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -298,65 +298,6 @@ export class NTQQFileApi { }); } - async addFileCache(peer: Peer, msgId: string, msgSeq: string, senderUid: string, elemId: string, elemType: string, fileSize: string, fileName: string) { - let GroupData; - let BuddyData; - if (peer.chatType === ChatType.KCHATTYPEGROUP) { - GroupData = - [{ - groupCode: peer.peerUid, - isConf: false, - hasModifyConfGroupFace: true, - hasModifyConfGroupName: true, - groupName: 'NapCat.Cached', - remark: 'NapCat.Cached', - }]; - } else if (peer.chatType === ChatType.KCHATTYPEC2C) { - BuddyData = [{ - category_name: 'NapCat.Cached', - peerUid: peer.peerUid, - peerUin: peer.peerUid, - remark: 'NapCat.Cached', - }]; - } else { - return undefined; - } - - return this.context.session.getSearchService().addSearchHistory({ - type: 4, - contactList: [], - id: -1, - groupInfos: [], - msgs: [], - fileInfos: [ - { - chatType: peer.chatType, - buddyChatInfo: BuddyData || [], - discussChatInfo: [], - groupChatInfo: GroupData || [], - dataLineChatInfo: [], - tmpChatInfo: [], - msgId: msgId, - msgSeq: msgSeq, - msgTime: Math.floor(Date.now() / 1000).toString(), - senderUid: senderUid, - senderNick: 'NapCat.Cached', - senderRemark: 'NapCat.Cached', - senderCard: 'NapCat.Cached', - elemId: elemId, - elemType: elemType, - fileSize: fileSize, - filePath: '', - fileName: fileName, - hits: [{ - start: 12, - end: 14, - }], - }, - ], - }); - } - async searchForFile(keys: string[]): Promise { const randomResultId = 100000 + Math.floor(Math.random() * 10000); let searchId = 0; diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index 85689dba..abf9e3e5 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -115,6 +115,7 @@ export class OneBotMsgApi { file_id: encodedFileId, url: await this.core.apis.FileApi.getImageUrl(element), file_size: element.fileSize, + file_unique: element.fileName }, }; } catch (e: any) { @@ -129,20 +130,6 @@ export class OneBotMsgApi { peerUid: msg.peerUid, guildId: '', }; - await this.core.apis.FileApi.addFileCache( - { - peerUid: msg.peerUid, - chatType: msg.chatType, - guildId: '', - }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - elementWrapper.elementId, - elementWrapper.elementType.toString(), - element.fileSize, - element.fileName, - ); return { type: OB11MessageDataType.file, data: { @@ -151,6 +138,7 @@ export class OneBotMsgApi { url: element.filePath, file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId), file_size: element.fileSize, + file_unique: element.fileName, }, }; }, @@ -182,20 +170,6 @@ export class OneBotMsgApi { }, marketFaceElement: async (_, msg, elementWrapper) => { - await this.core.apis.FileApi.addFileCache( - { - peerUid: msg.peerUid, - chatType: msg.chatType, - guildId: '', - }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - elementWrapper.elementId, - elementWrapper.elementType.toString(), - '0', - 'marketface', - ); const peer = { chatType: msg.chatType, peerUid: msg.peerUid, @@ -208,6 +182,7 @@ export class OneBotMsgApi { file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId), path: elementWrapper.elementId, url: elementWrapper.elementId, + file_unique: _.key }, }; }, @@ -283,21 +258,6 @@ export class OneBotMsgApi { videoDownUrl = element.filePath; } - await this.core.apis.FileApi.addFileCache( - { - peerUid: msg.peerUid, - chatType: msg.chatType, - guildId: '', - }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - elementWrapper.elementId, - elementWrapper.elementType.toString(), - element.fileSize ?? '0', - element.fileName, - ); - return { type: OB11MessageDataType.video, data: { @@ -306,6 +266,7 @@ export class OneBotMsgApi { url: videoDownUrl, file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId), file_size: element.fileSize, + file_unique: element.fileName, }, }; }, @@ -316,20 +277,6 @@ export class OneBotMsgApi { peerUid: msg.peerUid, guildId: '', }; - await this.core.apis.FileApi.addFileCache( - { - peerUid: msg.peerUid, - chatType: msg.chatType, - guildId: '', - }, - msg.msgId, - msg.msgSeq, - msg.senderUid, - elementWrapper.elementId, - elementWrapper.elementType.toString(), - element.fileSize || '0', - element.fileUuid || '', - ); return { type: OB11MessageDataType.voice, data: { diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 5206028b..e28e8b91 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V2.3.0', 'napcat-update-button', 'secondary'), + SettingButton('V2.3.2', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 820815dd..0055edc6 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.3.0", "napcat-update-button", "secondary") + SettingButton("V2.3.2", "napcat-update-button", "secondary") ) ]), SettingList([