refactor: MsgId

This commit is contained in:
手瓜一十雪 committed 2024-07-22 11:15:01 +08:00
1 parent 0522ba35fe
commit 334e43e764
18 files changed
+90 -104

No files matched your search

+4 -6
View File
@@ -1,8 +1,8 @@
import { ActionName } from '../types';
import BaseAction from '../BaseAction';
import { dbUtil } from '@/common/utils/db';
import { NTQQMsgApi } from '@/core/apis';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { MessageUnique } from '@/common/utils/MessageUnique';
const SchemaData = {
type: 'object',
@@ -19,16 +19,14 @@ export class SetMsgEmojiLike extends BaseAction<Payload, any> {
actionName = ActionName.SetMsgEmojiLike;
PayloadSchema = SchemaData;
protected async _handle(payload: Payload) {
const msg = await dbUtil.getMsgByShortId(parseInt(payload.message_id.toString()));
const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
if (!msg) {
throw new Error('msg not found');
}
if (!payload.emoji_id){
throw new Error('emojiId not found');
}
return await NTQQMsgApi.setEmojiLike({
chatType: msg.chatType,
peerUid: msg.peerUid
}, msg.msgSeq, payload.emoji_id.toString(), true);
let msgSeq = (await NTQQMsgApi.getMsgsByMsgId(msg.Peer, [msg.MsgId])).msgList[0].msgSeq;
return await NTQQMsgApi.setEmojiLike(msg.Peer, msgSeq, payload.emoji_id.toString(), true);
}
}