mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 16:20:25 +00:00
feat: action check data
This commit is contained in:
@@ -3,12 +3,19 @@ import { OB11ForwardMessage, OB11Message, OB11MessageData } from '../../types';
|
||||
import { NTQQMsgApi } from '@/core/apis';
|
||||
import { dbUtil } from '@/core/utils/db';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { ActionName } from '../types';
|
||||
import { ActionName, BaseCheckResult } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import Ajv from 'ajv';
|
||||
|
||||
interface Payload {
|
||||
message_id: string; // long msg id
|
||||
id?: string; // short msg id
|
||||
}
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
message_id: { type: 'string' },
|
||||
id: { type: 'string' }
|
||||
},
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
interface Response {
|
||||
messages: (OB11Message & { content: OB11MessageData })[];
|
||||
@@ -16,7 +23,7 @@ interface Response {
|
||||
|
||||
export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
||||
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
const msgId = payload.message_id || payload.id;
|
||||
if (!msgId) {
|
||||
@@ -25,7 +32,7 @@ export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
let rootMsg = await dbUtil.getMsgByLongId(msgId);
|
||||
if (!rootMsg) {
|
||||
rootMsg = await dbUtil.getMsgByShortId(parseInt(msgId));
|
||||
if (!rootMsg){
|
||||
if (!rootMsg) {
|
||||
throw Error('msg not found');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user