修复提交疏漏

修改在查询群历史消息时,如未提供msg_seq,则返回最新消息
This commit is contained in:
Alen
2024-07-27 15:01:08 +08:00
parent 3e5c92a2b1
commit e4ba9edeb8
2 changed files with 32 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ const SchemaData = {
message_seq: { type: 'number' },
count: { type: 'number' }
},
required: ['group_id', 'count']
required: [ 'group_id' ]
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
@@ -31,13 +31,16 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
if (!group) {
throw `${payload.group_id}不存在`;
}
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq || 0))?.MsgId || '0';
// log("startMsgId", startMsgId)
const historyResult = (await NTQQMsgApi.getMsgHistory({
let targetMsgShortId, count = parseInt(payload.count?.toString() ?? '20');
const peer = {
chatType: ChatType.group,
peerUid: group.groupCode
}, startMsgId, parseInt(payload.count?.toString()) || 20));
//logDebug(historyResult);
}
if ( !payload.message_seq ) {
targetMsgShortId = await MessageUnique.getNthLatestShortIdByPeer(peer, count)
}
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(targetMsgShortId ?? (payload.message_seq ?? 0)))?.MsgId || '0';
const historyResult = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, count));
const msgList = historyResult.msgList;
await Promise.all(msgList.map(async msg => {
msg.id = await MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);