mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
Revert "fix: fileId"
This reverts commit ae009f98c1bee7fd411488c8e6a47cc6b17280f1.
This commit is contained in:
parent
e9482e2ec4
commit
00f8e1c0da
@ -25,26 +25,24 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
|
||||
}
|
||||
|
||||
export class FileNapCatOneBotUUID {
|
||||
static encodeModelId(peer: Peer, modelId: string, fileId: string): string {
|
||||
return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}-${fileId}`;
|
||||
static encodeModelId(peer: Peer, modelId: string): string {
|
||||
return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}`;
|
||||
}
|
||||
|
||||
static decodeModelId(uuid: string): undefined | {
|
||||
peer: Peer,
|
||||
modelId: string,
|
||||
fileId: string
|
||||
modelId: string
|
||||
} {
|
||||
if (!uuid.startsWith('NapCatOneBot-ModelIdFile-')) return undefined;
|
||||
const data = uuid.split('-');
|
||||
if (data.length !== 6) return undefined;
|
||||
const [, , chatType, peerUid, modelId, fileId] = data;
|
||||
if (data.length !== 5) return undefined;
|
||||
const [, , chatType, peerUid, modelId] = data;
|
||||
return {
|
||||
peer: {
|
||||
chatType: chatType as any,
|
||||
peerUid: peerUid,
|
||||
},
|
||||
modelId,
|
||||
fileId
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@ -19,8 +18,6 @@ export class DelGroupFile extends BaseAction<Payload, any> {
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const file = FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
||||
if(!file) throw new Error('file_id is invalid');
|
||||
return await this.core.apis.GroupApi.DelGroupFile(payload.group_id.toString(), [file.fileId]);
|
||||
return await this.core.apis.GroupApi.DelGroupFile(payload.group_id.toString(), [payload.file_id]);
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ export class OB11Entities {
|
||||
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
||||
return {
|
||||
group_id: parseInt(peerId),
|
||||
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId, file.fileId),
|
||||
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId),
|
||||
file_name: file.fileName,
|
||||
busid: file.busId,
|
||||
size: parseInt(file.fileSize),
|
||||
|
Loading…
x
Reference in New Issue
Block a user