mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
refactor: MsgId
This commit is contained in:
@@ -4,6 +4,8 @@ import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||
import { NTQQMsgApi } from '@/core';
|
||||
|
||||
|
||||
export type ReturnDataType = OB11Message
|
||||
@@ -11,7 +13,7 @@ export type ReturnDataType = OB11Message
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
message_id: { type: ['number','string'] },
|
||||
message_id: { type: ['number', 'string'] },
|
||||
},
|
||||
required: ['message_id']
|
||||
} as const satisfies JSONSchema;
|
||||
@@ -26,14 +28,15 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
||||
if (!payload.message_id) {
|
||||
throw Error('参数message_id不能为空');
|
||||
}
|
||||
let msg = await dbUtil.getMsgByShortId(parseInt(payload.message_id.toString()));
|
||||
if (!msg) {
|
||||
msg = await dbUtil.getMsgByLongId(payload.message_id.toString());
|
||||
}
|
||||
if (!msg) {
|
||||
let MsgShortId = await MessageUnique.getShortIdByMsgId(payload.message_id.toString());
|
||||
let msgIdWithPeer = await MessageUnique.getMsgIdAndPeerByShortId(MsgShortId || parseInt(payload.message_id.toString()));
|
||||
if (!msgIdWithPeer) {
|
||||
throw ('消息不存在');
|
||||
}
|
||||
return await OB11Constructor.message(msg);
|
||||
let msg = await NTQQMsgApi.getMsgsByMsgId(
|
||||
{ guildId: '', peerUid: msgIdWithPeer?.Peer.peerUid, chatType: msgIdWithPeer.Peer.chatType },
|
||||
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
||||
return await OB11Constructor.message(msg.msgList[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user