mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: participant count
This commit is contained in:
@@ -243,7 +243,11 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
return didFetchNewSession
|
||||
}
|
||||
|
||||
const createParticipantNodes = async(jids: string[], bytes: Buffer) => {
|
||||
const createParticipantNodes = async(
|
||||
jids: string[],
|
||||
bytes: Buffer,
|
||||
extraAttrs?: BinaryNode['attrs']
|
||||
) => {
|
||||
let shouldIncludeDeviceIdentity = false
|
||||
const nodes = await Promise.all(
|
||||
jids.map(
|
||||
@@ -258,7 +262,11 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
attrs: { jid },
|
||||
content: [{
|
||||
tag: 'enc',
|
||||
attrs: { v: '2', type },
|
||||
attrs: {
|
||||
v: '2',
|
||||
type,
|
||||
...extraAttrs || {}
|
||||
},
|
||||
content: ciphertext
|
||||
}]
|
||||
}
|
||||
@@ -291,6 +299,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const binaryNodeContent: BinaryNode[] = []
|
||||
|
||||
const devices: JidWithDevice[] = []
|
||||
const extraParticipantNodeAttrs: BinaryNode['attrs'] = { }
|
||||
if(participant) {
|
||||
// when the retry request is not for a group
|
||||
// only send to the specific device that asked for a retry
|
||||
@@ -299,6 +308,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
additionalAttributes = { ...additionalAttributes, device_fanout: 'false' }
|
||||
}
|
||||
|
||||
extraParticipantNodeAttrs.count = participant.count.toString()
|
||||
|
||||
const { user, device } = jidDecode(participant.jid)!
|
||||
devices.push({ user, device })
|
||||
}
|
||||
@@ -362,7 +373,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
|
||||
await assertSessions(senderKeyJids, false)
|
||||
|
||||
const result = await createParticipantNodes(senderKeyJids, encSenderKeyMsg)
|
||||
const result = await createParticipantNodes(senderKeyJids, encSenderKeyMsg, extraParticipantNodeAttrs)
|
||||
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity
|
||||
|
||||
participants.push(...result.nodes)
|
||||
@@ -414,8 +425,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
{ nodes: meNodes, shouldIncludeDeviceIdentity: s1 },
|
||||
{ nodes: otherNodes, shouldIncludeDeviceIdentity: s2 }
|
||||
] = await Promise.all([
|
||||
createParticipantNodes(meJids, encodedMeMsg),
|
||||
createParticipantNodes(otherJids, encodedMsg)
|
||||
createParticipantNodes(meJids, encodedMeMsg, extraParticipantNodeAttrs),
|
||||
createParticipantNodes(otherJids, encodedMsg, extraParticipantNodeAttrs)
|
||||
])
|
||||
participants.push(...meNodes)
|
||||
participants.push(...otherNodes)
|
||||
@@ -423,12 +434,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2
|
||||
}
|
||||
|
||||
if(participant?.count) {
|
||||
for(const node of participants) {
|
||||
node.attrs.count = participant.count.toString()
|
||||
}
|
||||
}
|
||||
|
||||
if(participants.length) {
|
||||
binaryNodeContent.push({
|
||||
tag: 'participants',
|
||||
|
||||
Reference in New Issue
Block a user