From ce57b7b72580a113a452483324412b7d41bfae8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 11 Nov 2024 21:00:12 +0800 Subject: [PATCH] fix: #509 --- src/onebot/action/msg/MarkMsgAsRead.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/onebot/action/msg/MarkMsgAsRead.ts b/src/onebot/action/msg/MarkMsgAsRead.ts index 279f4966..fe8c5ec5 100644 --- a/src/onebot/action/msg/MarkMsgAsRead.ts +++ b/src/onebot/action/msg/MarkMsgAsRead.ts @@ -2,12 +2,14 @@ import { ChatType, Peer } from '@/core/entities'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; +import { MessageUnique } from '@/common/message-unique'; const SchemaData = { type: 'object', properties: { user_id: { type: ['number', 'string'] }, group_id: { type: ['number', 'string'] }, + message_id: { type: ['number', 'string'] }, }, } as const satisfies JSONSchema; @@ -15,6 +17,16 @@ type PlayloadType = FromSchema; class MarkMsgAsRead extends BaseAction { async getPeer(payload: PlayloadType): Promise { + if (payload.message_id) { + let s_peer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)?.Peer; + if (s_peer) { + return s_peer; + } + let l_peer = MessageUnique.getPeerByMsgId(payload.message_id.toString())?.Peer; + if (l_peer) { + return l_peer; + } + } if (payload.user_id) { const peerUid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); if (!peerUid) {