fix(onebot): 修复 create_flash_task 触发的 QQ 内核崩溃,并新增时效字段 (#2098)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { GeneralCallResult, InstanceContext, NapCatCore } from '@/napcat-core';
|
||||
import {
|
||||
createFlashTransferResult,
|
||||
DEFAULT_FLASH_VALIDITY_SECONDS,
|
||||
FileListResponse,
|
||||
FlashFileSetInfo,
|
||||
SendStatus,
|
||||
@@ -22,8 +23,9 @@ export class NTQQFlashApi {
|
||||
* @param fileListToUpload 上传文件绝对路径的列表,可以是文件夹!!
|
||||
* @param thumbnailPath
|
||||
* @param filesetName
|
||||
* @param validitySeconds 文件集有效期(秒),默认 1209600(14 天),可选 90 天 / 180 天,必须传否则新版内核段错误
|
||||
*/
|
||||
async createFlashTransferUploadTask (fileListToUpload: string[], thumbnailPath: string, filesetName: string): Promise<GeneralCallResult & {
|
||||
async createFlashTransferUploadTask (fileListToUpload: string[], thumbnailPath: string, filesetName: string, validitySeconds: number = DEFAULT_FLASH_VALIDITY_SECONDS): Promise<GeneralCallResult & {
|
||||
createFlashTransferResult: createFlashTransferResult;
|
||||
seq: number;
|
||||
}> {
|
||||
@@ -33,14 +35,17 @@ export class NTQQFlashApi {
|
||||
const selfInfo = this.core.selfInfo;
|
||||
|
||||
const fileUploadArg = {
|
||||
screen: 1, // 1
|
||||
scene: 1, // 1
|
||||
name: filesetName,
|
||||
uploaders: [{
|
||||
uin: selfInfo.uin,
|
||||
nickname: selfInfo.nick,
|
||||
uid: selfInfo.uid,
|
||||
sendEntrance: '',
|
||||
nickname: selfInfo.nick,
|
||||
}],
|
||||
permission: {
|
||||
code: 0,
|
||||
},
|
||||
coverPath: thumbnailPath,
|
||||
paths: fileListToUpload,
|
||||
excludePaths: [],
|
||||
@@ -56,8 +61,15 @@ export class NTQQFlashApi {
|
||||
uploadSceneType: UploadSceneType.KUPLOADSCENEAIOFILESELECTOR, // 不知道怎么枚举 先硬编码吧 (PC QQ 10)
|
||||
detectPrivacyInfoResult: {
|
||||
exists: false,
|
||||
allDetectResults: new Map(),
|
||||
allDetectResults: {},
|
||||
},
|
||||
announcement: {
|
||||
announcementSegments: [],
|
||||
modifyTime: '',
|
||||
avatarUrl: '',
|
||||
},
|
||||
albumFilePathList: [],
|
||||
validitySeconds,
|
||||
};
|
||||
|
||||
const uploadResult = await flashService.createFlashTransferUploadTask(timestamp, fileUploadArg);
|
||||
|
||||
@@ -214,15 +214,19 @@ export enum UploadSceneType {
|
||||
KUPLOADSCENEAIOFILESELECTOR,
|
||||
KUPLOADSCENEAIOSHORTCUTKEYCTRLCV,
|
||||
}
|
||||
/** 闪传文件集默认有效期(秒):14 天 */
|
||||
export const DEFAULT_FLASH_VALIDITY_SECONDS = 1209600;
|
||||
|
||||
export interface StartFlashTaskRequests {
|
||||
screen: number; // 1 PC-QQ
|
||||
scene: number; // 1 PC-QQ
|
||||
name?: string;
|
||||
uploaders: UploaderInfo[];
|
||||
permission?: {};
|
||||
permission?: { code: number; };
|
||||
coverPath?: string;
|
||||
paths: string[]; // 文件的绝对路径,可以是文件夹
|
||||
excludePaths?: string[];
|
||||
expireLeftTime?: number, // 0
|
||||
validitySeconds: number, // 文件集有效期(秒):14 天 1209600 / 90 天 7776000 / 180 天 15552000,必须传,否则新版内核段错误
|
||||
isNeedDelDeviceInfo: boolean,
|
||||
isNeedDelLocation: boolean,
|
||||
coverOriginalInfos?: {
|
||||
@@ -234,6 +238,12 @@ export interface StartFlashTaskRequests {
|
||||
exists: boolean,
|
||||
allDetectResults: {};
|
||||
};
|
||||
announcement: {
|
||||
announcementSegments: unknown[],
|
||||
modifyTime: string,
|
||||
avatarUrl: string;
|
||||
};
|
||||
albumFilePathList: unknown[];
|
||||
}
|
||||
export enum BusiScene {
|
||||
KBUSISCENEINVALID,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/napcat-onebot/action/router';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import path from 'node:path';
|
||||
import { DEFAULT_FLASH_VALIDITY_SECONDS } from '@/napcat-core/data/flash';
|
||||
|
||||
const richMediaList = [
|
||||
'.mp4', '.mov', '.avi', '.wmv', '.mpeg', '.mpg', '.flv', '.mkv',
|
||||
@@ -15,6 +16,7 @@ export const CreateFlashTaskPayloadSchema = Type.Object({
|
||||
], { description: '文件列表或单个文件路径' }),
|
||||
name: Type.Optional(Type.String({ description: '任务名称' })),
|
||||
thumb_path: Type.Optional(Type.String({ description: '缩略图路径' })),
|
||||
validitySeconds: Type.Optional(Type.Number({ description: '文件集有效期(秒),可选 14 天 1209600 / 90 天 7776000 / 180 天 15552000,默认 1209600' })),
|
||||
});
|
||||
export type CreateFlashTaskPayload = Static<typeof CreateFlashTaskPayloadSchema>;
|
||||
|
||||
@@ -27,6 +29,7 @@ export class CreateFlashTask extends OneBotAction<CreateFlashTaskPayload, any> {
|
||||
override payloadExample = {
|
||||
files: 'C:\\test.jpg',
|
||||
name: 'test_task',
|
||||
validitySeconds: DEFAULT_FLASH_VALIDITY_SECONDS,
|
||||
};
|
||||
|
||||
override returnExample = {
|
||||
@@ -67,6 +70,7 @@ export class CreateFlashTask extends OneBotAction<CreateFlashTaskPayload, any> {
|
||||
} else {
|
||||
normalPath = toPlatformPath(thumbPath);
|
||||
}
|
||||
return await this.core.apis.FlashApi.createFlashTransferUploadTask(fileList, normalPath, payload.name || '');
|
||||
const validitySeconds = payload.validitySeconds ?? DEFAULT_FLASH_VALIDITY_SECONDS;
|
||||
return await this.core.apis.FlashApi.createFlashTransferUploadTask(fileList, normalPath, payload.name || '', validitySeconds);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user