chore: run a full eslint

This commit is contained in:
Wesley F. Young
2024-08-10 19:58:31 +08:00
parent 9a9511aad6
commit 116a04e081
198 changed files with 8187 additions and 7744 deletions

View File

@@ -6,26 +6,28 @@ import { ChatType, ElementType, FileElement, Peer, RawMessage, VideoElement } fr
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
export interface GetFilePayload {
file: string; // 文件名或者fileUuid
file: string; // 文件名或者fileUuid
}
export interface GetFileResponse {
file?: string; // path
url?: string;
file_size?: string;
file_name?: string;
base64?: string;
file?: string; // path
url?: string;
file_size?: string;
file_name?: string;
base64?: string;
}
const GetFileBase_PayloadSchema = {
type: 'object',
properties: {
file: { type: 'string' }
file: { type: 'string' },
},
required: ['file']
required: ['file'],
} as const satisfies JSONSchema;
export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
PayloadSchema: any = GetFileBase_PayloadSchema;
private getElement(msg: RawMessage): { id: string, element: VideoElement | FileElement } {
let element = msg.elements.find(e => e.fileElement);
if (!element) {
@@ -38,6 +40,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
}
return { id: element.elementId, element: element.fileElement };
}
protected async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
const NTQQFriendApi = this.CoreContext.getApiContext().FriendApi;
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
@@ -45,9 +48,9 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
const NTQQGroupApi = this.CoreContext.getApiContext().GroupApi;
const NTQQFileApi = this.CoreContext.getApiContext().FileApi;
let UuidData: {
high: string;
low: string;
} | undefined;
high: string;
low: string;
} | undefined;
try {
UuidData = UUIDConverter.decode(payload.file);
if (UuidData) {
@@ -87,7 +90,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
file: downloadPath,
url: downloadPath,
file_size: fileSize,
file_name: fileName
file_name: fileName,
};
if (true/*enableLocalFile2Url*/) {
try {
@@ -127,7 +130,7 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
file: downloadPath,
url: downloadPath,
file_size: NTSearchNameResult[0].fileSize.toString(),
file_name: NTSearchNameResult[0].fileName
file_name: NTSearchNameResult[0].fileName,
};
if (true/*enableLocalFile2Url*/) {
try {
@@ -182,24 +185,24 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
// // }
// }
// }
// // log('file found', cache);
// const res: GetFileResponse = {
// file: cache.path,
// url: cache.url,
// file_size: cache.size.toString(),
// file_name: cache.name
// };
// if (enableLocalFile2Url) {
// if (!cache.url) {
// try {
// res.base64 = await fs.readFile(cache.path, 'base64');
// } catch (e) {
// throw new Error('文件下载失败. ' + e);
// }
// }
// }
//return res;
// }
// // log('file found', cache);
// const res: GetFileResponse = {
// file: cache.path,
// url: cache.url,
// file_size: cache.size.toString(),
// file_name: cache.name
// };
// if (enableLocalFile2Url) {
// if (!cache.url) {
// try {
// res.base64 = await fs.readFile(cache.path, 'base64');
// } catch (e) {
// throw new Error('文件下载失败. ' + e);
// }
// }
// }
//return res;
}
}
@@ -207,20 +210,21 @@ const GetFile_PayloadSchema = {
type: 'object',
properties: {
file_id: { type: 'string' },
file: { type: 'string' }
file: { type: 'string' },
},
required: ['file_id']
required: ['file_id'],
} as const satisfies JSONSchema;
type GetFile_Payload_Internal = FromSchema<typeof GetFile_PayloadSchema>;
interface GetFile_Payload extends GetFile_Payload_Internal {
file: string
file: string;
}
export default class GetFile extends GetFileBase {
actionName = ActionName.GetFile;
PayloadSchema = GetFile_PayloadSchema;
protected async _handle(payload: GetFile_Payload): Promise<GetFileResponse> {
payload.file = payload.file_id;
return super._handle(payload);