mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: 缓存文件
This commit is contained in:
parent
97cb351827
commit
f2e4579fd8
@ -143,6 +143,64 @@ export class NTQQFileApi {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
static 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.group) {
|
||||||
|
GroupData =
|
||||||
|
[{
|
||||||
|
groupCode: peer.peerUid,
|
||||||
|
isConf: false,
|
||||||
|
hasModifyConfGroupFace: true,
|
||||||
|
hasModifyConfGroupName: true,
|
||||||
|
groupName: "NapCat.Cached",
|
||||||
|
remark: "NapCat.Cached"
|
||||||
|
}];
|
||||||
|
} else if (peer.chatType === ChatType.friend) {
|
||||||
|
BuddyData = [{
|
||||||
|
category_name: 'NapCat.Cached',
|
||||||
|
peerUid: peer.peerUid,
|
||||||
|
peerUin: peer.peerUid,
|
||||||
|
remark: 'NapCat.Cached'
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return napCatCore.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
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
static async searchfile(keys: string[]) {
|
static async searchfile(keys: string[]) {
|
||||||
type EventType = NodeIKernelSearchService['searchFileWithKeywords'];
|
type EventType = NodeIKernelSearchService['searchFileWithKeywords'];
|
||||||
interface OnListener {
|
interface OnListener {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { ChatType } from "../entities";
|
||||||
|
|
||||||
export interface NodeIKernelSearchService {
|
export interface NodeIKernelSearchService {
|
||||||
addKernelSearchListener(...args: any[]): unknown;// needs 1 arguments
|
addKernelSearchListener(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
@ -7,7 +9,7 @@ export interface NodeIKernelSearchService {
|
|||||||
|
|
||||||
searchGroup(...args: any[]): unknown;// needs 1 arguments
|
searchGroup(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
searchLocalInfo(keywords: string,unknown:number/*4*/): unknown;
|
searchLocalInfo(keywords: string, unknown: number/*4*/): unknown;
|
||||||
|
|
||||||
cancelSearchLocalInfo(...args: any[]): unknown;// needs 3 arguments
|
cancelSearchLocalInfo(...args: any[]): unknown;// needs 3 arguments
|
||||||
|
|
||||||
@ -69,7 +71,55 @@ export interface NodeIKernelSearchService {
|
|||||||
|
|
||||||
cancelSearchChatAtMeMsgs(...args: any[]): unknown;// needs 3 arguments
|
cancelSearchChatAtMeMsgs(...args: any[]): unknown;// needs 3 arguments
|
||||||
|
|
||||||
addSearchHistory(...args: any[]): unknown;// needs 1 arguments
|
addSearchHistory(param: {
|
||||||
|
type: number,//4
|
||||||
|
contactList: [],
|
||||||
|
id: number,//-1
|
||||||
|
groupInfos: [],
|
||||||
|
msgs: [],
|
||||||
|
fileInfos: [
|
||||||
|
{
|
||||||
|
chatType: ChatType,
|
||||||
|
buddyChatInfo: Array<{ category_name: string, peerUid: string, peerUin: string, remark: string }>,
|
||||||
|
discussChatInfo: [],
|
||||||
|
groupChatInfo: Array<
|
||||||
|
{
|
||||||
|
groupCode: string,
|
||||||
|
isConf: boolean,
|
||||||
|
hasModifyConfGroupFace: boolean,
|
||||||
|
hasModifyConfGroupName: boolean,
|
||||||
|
groupName: string,
|
||||||
|
remark: string
|
||||||
|
}>
|
||||||
|
,
|
||||||
|
dataLineChatInfo: [],
|
||||||
|
tmpChatInfo: [],
|
||||||
|
msgId: string,
|
||||||
|
msgSeq: string,
|
||||||
|
msgTime: string,
|
||||||
|
senderUid: string,
|
||||||
|
senderNick: string,
|
||||||
|
senderRemark: string,
|
||||||
|
senderCard: string,
|
||||||
|
elemId: string,
|
||||||
|
elemType: string,//3
|
||||||
|
fileSize: string,
|
||||||
|
filePath: string,
|
||||||
|
fileName: string,
|
||||||
|
hits: Array<
|
||||||
|
{
|
||||||
|
start: 12,
|
||||||
|
end: 14
|
||||||
|
}
|
||||||
|
>
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}): Promise<{
|
||||||
|
result: number,
|
||||||
|
errMsg: string,
|
||||||
|
id?: number
|
||||||
|
}>;
|
||||||
|
|
||||||
removeSearchHistory(...args: any[]): unknown;// needs 1 arguments
|
removeSearchHistory(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
|
@ -193,13 +193,27 @@ export class OB11Constructor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else if (element.fileElement) {
|
else if (element.fileElement) {
|
||||||
const FileElement = element.videoElement || element.fileElement;
|
|
||||||
|
const FileElement = element.fileElement;
|
||||||
message_data['type'] = OB11MessageDataType.file;
|
message_data['type'] = OB11MessageDataType.file;
|
||||||
message_data['data']['file'] = FileElement.fileName;
|
message_data['data']['file'] = FileElement.fileName;
|
||||||
message_data['data']['path'] = FileElement.filePath;
|
message_data['data']['path'] = FileElement.filePath;
|
||||||
message_data['data']['url'] = FileElement.filePath;
|
message_data['data']['url'] = FileElement.filePath;
|
||||||
message_data['data']['file_id'] = FileElement.fileUuid;
|
message_data['data']['file_id'] = FileElement.fileUuid;
|
||||||
message_data['data']['file_size'] = FileElement.fileSize;
|
message_data['data']['file_size'] = FileElement.fileSize;
|
||||||
|
await NTQQFileApi.addFileCache({
|
||||||
|
peerUid: msg.peerUid,
|
||||||
|
chatType: msg.chatType,
|
||||||
|
guildId: '',
|
||||||
|
},
|
||||||
|
msg.msgId,
|
||||||
|
msg.msgSeq,
|
||||||
|
msg.senderUid,
|
||||||
|
element.elementId,
|
||||||
|
element.elementType.toString(),
|
||||||
|
FileElement.fileSize,
|
||||||
|
FileElement.fileName
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if (element.videoElement) {
|
else if (element.videoElement) {
|
||||||
const videoElement: VideoElement = element.videoElement;
|
const videoElement: VideoElement = element.videoElement;
|
||||||
@ -233,6 +247,20 @@ export class OB11Constructor {
|
|||||||
message_data['data']['url'] = videoDownUrl;
|
message_data['data']['url'] = videoDownUrl;
|
||||||
message_data['data']['file_id'] = videoElement.fileUuid;
|
message_data['data']['file_id'] = videoElement.fileUuid;
|
||||||
message_data['data']['file_size'] = videoElement.fileSize;
|
message_data['data']['file_size'] = videoElement.fileSize;
|
||||||
|
|
||||||
|
await NTQQFileApi.addFileCache({
|
||||||
|
peerUid: msg.peerUid,
|
||||||
|
chatType: msg.chatType,
|
||||||
|
guildId: '',
|
||||||
|
},
|
||||||
|
msg.msgId,
|
||||||
|
msg.msgSeq,
|
||||||
|
msg.senderUid,
|
||||||
|
element.elementId,
|
||||||
|
element.elementType.toString(),
|
||||||
|
videoElement.fileSize || '0',
|
||||||
|
videoElement.fileName
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if (element.pttElement) {
|
else if (element.pttElement) {
|
||||||
message_data['type'] = OB11MessageDataType.voice;
|
message_data['type'] = OB11MessageDataType.voice;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user