chore: OBAPI

This commit is contained in:
手瓜一十雪
2024-08-09 16:22:35 +08:00
parent d9e016db8b
commit ff29b62398
16 changed files with 28 additions and 165 deletions

View File

@@ -16,6 +16,7 @@ type PlayloadType = FromSchema<typeof SchemaData>;
class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
async getPeer(payload: PlayloadType): Promise<Peer> {
const NTQQUserApi = this.CoreContext.getApiContext().UserApi;
if (payload.user_id) {
const peerUid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
if (!peerUid) {
@@ -30,6 +31,7 @@ class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
return { chatType: ChatType.group, peerUid: payload.group_id.toString() };
}
protected async _handle(payload: PlayloadType): Promise<null> {
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
// 调用API
const ret = await NTQQMsgApi.setMsgRead(await this.getPeer(payload));
if (ret.result != 0) {
@@ -65,6 +67,7 @@ export class MarkAllMsgAsRead extends BaseAction<Payload, null> {
actionName = ActionName._MarkAllMsgAsRead;
protected async _handle(payload: Payload): Promise<null> {
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
await NTQQMsgApi.markallMsgAsRead();
return null;
}