Revert "fix: fileId"

This reverts commit ae009f98c1bee7fd411488c8e6a47cc6b17280f1.
This commit is contained in:
手瓜一十雪 2024-09-01 13:41:19 +08:00
parent e9482e2ec4
commit 00f8e1c0da
3 changed files with 7 additions and 12 deletions

View File

@ -25,26 +25,24 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
} }
export class FileNapCatOneBotUUID { export class FileNapCatOneBotUUID {
static encodeModelId(peer: Peer, modelId: string, fileId: string): string { static encodeModelId(peer: Peer, modelId: string): string {
return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}-${fileId}`; return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}`;
} }
static decodeModelId(uuid: string): undefined | { static decodeModelId(uuid: string): undefined | {
peer: Peer, peer: Peer,
modelId: string, modelId: string
fileId: string
} { } {
if (!uuid.startsWith('NapCatOneBot-ModelIdFile-')) return undefined; if (!uuid.startsWith('NapCatOneBot-ModelIdFile-')) return undefined;
const data = uuid.split('-'); const data = uuid.split('-');
if (data.length !== 6) return undefined; if (data.length !== 5) return undefined;
const [, , chatType, peerUid, modelId, fileId] = data; const [, , chatType, peerUid, modelId] = data;
return { return {
peer: { peer: {
chatType: chatType as any, chatType: chatType as any,
peerUid: peerUid, peerUid: peerUid,
}, },
modelId, modelId,
fileId
}; };
} }

View File

@ -1,7 +1,6 @@
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import BaseAction from '../BaseAction'; import BaseAction from '../BaseAction';
import { ActionName } from '../types'; import { ActionName } from '../types';
import { FileNapCatOneBotUUID } from '@/common/helper';
const SchemaData = { const SchemaData = {
type: 'object', type: 'object',
@ -19,8 +18,6 @@ export class DelGroupFile extends BaseAction<Payload, any> {
payloadSchema = SchemaData; payloadSchema = SchemaData;
async _handle(payload: Payload) { async _handle(payload: Payload) {
const file = FileNapCatOneBotUUID.decodeModelId(payload.file_id); return await this.core.apis.GroupApi.DelGroupFile(payload.group_id.toString(), [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]);
} }
} }

View File

@ -109,7 +109,7 @@ export class OB11Entities {
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile { static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
return { return {
group_id: parseInt(peerId), 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, file_name: file.fileName,
busid: file.busId, busid: file.busId,
size: parseInt(file.fileSize), size: parseInt(file.fileSize),