Skip to content

Commit

Permalink
fix(api): fix common send
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed Sep 1, 2024
1 parent c3d3974 commit 5467e7b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/engine-chronocat-api/src/common/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ export const commonSend = async (
peer: Partial<Peer>,
elements: O.Partial<Element, 'deep'>[],
) => {
const privatePeerUid = await ctx.chronocat.uix.getUid2(peer.peerUid!)
if (!privatePeerUid) {
ctx.chronocat.l.error('内部错误', {
code: 2152,
throw: true,
})
return Promise.resolve<RedMessage>(undefined as unknown as RedMessage)
let privatePeerUid: string | undefined = undefined

if (peer.chatType === ChatType.Private) {
privatePeerUid = await ctx.chronocat.uix.getUid2(peer.peerUid!)
if (!privatePeerUid) {
ctx.chronocat.l.error('内部错误', {
code: 2152,
throw: true,
})
return Promise.resolve<RedMessage>(undefined as unknown as RedMessage)
}
}

const param = {
Expand All @@ -26,7 +30,7 @@ export const commonSend = async (
peer.chatType === ChatType.Private
? {
chatType: ChatType.Private,
peerUid: privatePeerUid,
peerUid: privatePeerUid!,
}
: (peer as Peer),
msgElements: elements,
Expand Down

0 comments on commit 5467e7b

Please sign in to comment.