fix(api): fix common send

This commit is contained in:
Il Harper 2024-09-01 22:55:00 +08:00
parent c3d3974643
commit 5467e7bfd9
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC

View File

@ -10,13 +10,17 @@ export const commonSend = async (
peer: Partial<Peer>, peer: Partial<Peer>,
elements: O.Partial<Element, 'deep'>[], elements: O.Partial<Element, 'deep'>[],
) => { ) => {
const privatePeerUid = await ctx.chronocat.uix.getUid2(peer.peerUid!) let privatePeerUid: string | undefined = undefined
if (!privatePeerUid) {
ctx.chronocat.l.error('内部错误', { if (peer.chatType === ChatType.Private) {
code: 2152, privatePeerUid = await ctx.chronocat.uix.getUid2(peer.peerUid!)
throw: true, if (!privatePeerUid) {
}) ctx.chronocat.l.error('内部错误', {
return Promise.resolve<RedMessage>(undefined as unknown as RedMessage) code: 2152,
throw: true,
})
return Promise.resolve<RedMessage>(undefined as unknown as RedMessage)
}
} }
const param = { const param = {
@ -26,7 +30,7 @@ export const commonSend = async (
peer.chatType === ChatType.Private peer.chatType === ChatType.Private
? { ? {
chatType: ChatType.Private, chatType: ChatType.Private,
peerUid: privatePeerUid, peerUid: privatePeerUid!,
} }
: (peer as Peer), : (peer as Peer),
msgElements: elements, msgElements: elements,