mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: pass cachedGroupMetadata from sendMessage
This commit is contained in:
@@ -315,6 +315,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
const [groupData, senderKeyMap] = await Promise.all([
|
const [groupData, senderKeyMap] = await Promise.all([
|
||||||
(async() => {
|
(async() => {
|
||||||
let groupData = cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined
|
let groupData = cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined
|
||||||
|
if(groupData) {
|
||||||
|
logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata')
|
||||||
|
}
|
||||||
|
|
||||||
if(!groupData) {
|
if(!groupData) {
|
||||||
groupData = await groupMetadata(jid)
|
groupData = await groupMetadata(jid)
|
||||||
}
|
}
|
||||||
@@ -501,7 +505,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
additionalAttributes.edit = '7'
|
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) {
|
if(config.emitOwnEvents) {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' })
|
ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' })
|
||||||
|
|||||||
@@ -131,27 +131,28 @@ export type AnyMessageContent = AnyRegularMessageContent | {
|
|||||||
|
|
||||||
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>
|
export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>
|
||||||
|
|
||||||
export type MessageRelayOptions = {
|
type MinimalRelayOptions = {
|
||||||
/** override the message ID with a custom provided string */
|
/** override the message ID with a custom provided string */
|
||||||
messageId?: 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 */
|
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
||||||
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>
|
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MiscMessageGenerationOptions = {
|
export type MessageRelayOptions = MinimalRelayOptions & {
|
||||||
/** Force message id */
|
/** only send to a specific participant; used when a message decryption fails for a single user */
|
||||||
messageId?: string
|
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 */
|
/** optional, if you want to manually set the timestamp of the message */
|
||||||
timestamp?: Date
|
timestamp?: Date
|
||||||
/** the message you want to quote */
|
/** the message you want to quote */
|
||||||
quoted?: WAMessage
|
quoted?: WAMessage
|
||||||
/** disappearing messages settings */
|
/** disappearing messages settings */
|
||||||
ephemeralExpiration?: number | string
|
ephemeralExpiration?: number | string
|
||||||
|
/** timeout for media upload to WA server */
|
||||||
mediaUploadTimeoutMs?: number
|
mediaUploadTimeoutMs?: number
|
||||||
}
|
}
|
||||||
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
||||||
|
|||||||
Reference in New Issue
Block a user