mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 21:10:23 +00:00
refactor: msgId stage-2
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11ForwardMessage, OB11Message, OB11MessageData } from '../../types';
|
||||
import { NTQQMsgApi } from '@/core/apis';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
import { ActionName, BaseCheckResult } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import Ajv from 'ajv';
|
||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||
|
||||
const SchemaData = {
|
||||
@@ -42,7 +40,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
const msgList = data.msgList;
|
||||
const messages = await Promise.all(msgList.map(async msg => {
|
||||
const resMsg = await OB11Constructor.message(msg);
|
||||
resMsg.message_id = await dbUtil.addMsg(msg);
|
||||
resMsg.message_id = await MessageUnique.createMsg({guildId:'',chatType:msg.chatType,peerUid:msg.peerUid},msg.msgId)!;
|
||||
return resMsg;
|
||||
}));
|
||||
messages.map(msg => {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { OB11Message } from '../../types';
|
||||
import { OB11Constructor } from '../../constructor';
|
||||
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';
|
||||
|
||||
@@ -17,6 +17,7 @@ import { uri2local } from '@/common/utils/file';
|
||||
import { ob11Config } from '@/onebot11/config';
|
||||
import { RequestUtil } from '@/common/utils/request';
|
||||
import fs from 'node:fs';
|
||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||
|
||||
export type MessageContext = {
|
||||
group?: Group,
|
||||
@@ -36,10 +37,10 @@ async function handleOb11FileLikeMessage(
|
||||
} else if (cache.url) {
|
||||
uri = cache.url;
|
||||
} else {
|
||||
const fileMsg = await dbUtil.getMsgByLongId(cache.msgId);
|
||||
if (fileMsg) {
|
||||
const fileMsgPeer = MessageUnique.getPeerByMsgId(cache.msgId);
|
||||
if (fileMsgPeer) {
|
||||
cache.path = await NTQQFileApi.downloadMedia(
|
||||
fileMsg.msgId, fileMsg.chatType, fileMsg.peerUid,
|
||||
fileMsgPeer.MsgId, fileMsgPeer.Peer.chatType, fileMsgPeer.Peer.peerUid,
|
||||
cache.elementId, '', ''
|
||||
);
|
||||
uri = 'file://' + cache.path;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ChatType, ElementType, Group, NTQQMsgApi, Peer, RawMessage, SendMessageElement } from '@/core';
|
||||
import { OB11MessageNode } from '@/onebot11/types';
|
||||
import { selfInfo } from '@/core/data';
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import createSendElements from '@/onebot11/action/msg/SendMsg/create-send-elements';
|
||||
import { logDebug, logError } from '@/common/utils/log';
|
||||
import { sleep } from '@/common/utils/helper';
|
||||
@@ -115,7 +114,8 @@ export async function handleForwardNode(destPeer: Peer, messageNodes: OB11Messag
|
||||
let srcPeer: Peer | undefined = undefined;
|
||||
let needSendSelf = false;
|
||||
for (const msgId of nodeMsgIds) {
|
||||
const nodeMsg = await dbUtil.getMsgByLongId(msgId);
|
||||
const nodeMsgPeer = await MessageUnique.getPeerByMsgId(msgId);
|
||||
let nodeMsg = (await NTQQMsgApi.getMsgsByMsgId(nodeMsgPeer?.Peer!, [msgId])).msgList[0];
|
||||
if (nodeMsg) {
|
||||
nodeMsgArray.push(nodeMsg);
|
||||
if (!srcPeer) {
|
||||
|
||||
Reference in New Issue
Block a user