mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-01 15:29:05 +08:00
29 lines
810 B
TypeScript
29 lines
810 B
TypeScript
import { NTQQMsgApi } from '@/core/apis';
|
|
import { ActionName } from '../types';
|
|
import BaseAction from '../BaseAction';
|
|
import { dbUtil } from '@/core/utils/db';
|
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
|
|
const SchemaData = {
|
|
type: 'object',
|
|
properties: {
|
|
message_id: { type: 'number' },
|
|
},
|
|
required: ['message_id']
|
|
} as const satisfies JSONSchema;
|
|
|
|
type Payload = FromSchema<typeof SchemaData>;
|
|
|
|
class DeleteMsg extends BaseAction<Payload, void> {
|
|
actionName = ActionName.DeleteMsg;
|
|
PayloadSchema = SchemaData;
|
|
protected async _handle(payload: Payload) {
|
|
const msg = await dbUtil.getMsgByShortId(payload.message_id);
|
|
if (msg) {
|
|
await NTQQMsgApi.recallMsg({ peerUid: msg.peerUid, chatType: msg.chatType }, [msg.msgId]);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default DeleteMsg;
|