diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 463333a..ca6ac55 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -315,6 +315,10 @@ export const makeMessagesSocket = (config: SocketConfig) => { const [groupData, senderKeyMap] = await Promise.all([ (async() => { let groupData = cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined + if(groupData) { + logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata') + } + if(!groupData) { groupData = await groupMetadata(jid) } @@ -501,7 +505,7 @@ export const makeMessagesSocket = (config: SocketConfig) => { additionalAttributes.edit = '7' } - await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id!, additionalAttributes }) + await relayMessage(jid, fullMsg.message, { messageId: fullMsg.key.id!, cachedGroupMetadata: options.cachedGroupMetadata, additionalAttributes }) if(config.emitOwnEvents) { process.nextTick(() => { ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' }) diff --git a/src/Types/Message.ts b/src/Types/Message.ts index 023f597..b70efc5 100644 --- a/src/Types/Message.ts +++ b/src/Types/Message.ts @@ -131,27 +131,28 @@ export type AnyMessageContent = AnyRegularMessageContent | { export type GroupMetadataParticipants = Pick -export type MessageRelayOptions = { +type MinimalRelayOptions = { /** override the message ID with a custom provided string */ messageId?: string - /** only send to a specific participant; used when a message decryption fails for a single user */ - participant?: string - /** additional attributes to add to the WA binary node */ - additionalAttributes?: { [_: string]: string } /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */ cachedGroupMetadata?: (jid: string) => Promise } -export type MiscMessageGenerationOptions = { - /** Force message id */ - messageId?: string +export type MessageRelayOptions = MinimalRelayOptions & { + /** only send to a specific participant; used when a message decryption fails for a single user */ + participant?: string + /** additional attributes to add to the WA binary node */ + additionalAttributes?: { [_: string]: string } +} + +export type MiscMessageGenerationOptions = MinimalRelayOptions & { /** optional, if you want to manually set the timestamp of the message */ timestamp?: Date /** the message you want to quote */ quoted?: WAMessage /** disappearing messages settings */ ephemeralExpiration?: number | string - + /** timeout for media upload to WA server */ mediaUploadTimeoutMs?: number } export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {