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