@hansaka02/baileys 7.3.4 → 7.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +203 -247
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/connection.js +1 -1
- package/lib/Defaults/constants.js +13 -1
- package/lib/Defaults/history.js +3 -1
- package/lib/Signal/Group/sender-chain-key.js +1 -14
- package/lib/Signal/Group/sender-key-distribution-message.js +2 -2
- package/lib/Signal/Group/sender-key-record.js +2 -11
- package/lib/Signal/Group/sender-key-state.js +11 -57
- package/lib/Signal/libsignal.js +200 -116
- package/lib/Signal/lid-mapping.js +121 -68
- package/lib/Socket/Client/websocket.js +9 -2
- package/lib/Socket/business.js +5 -1
- package/lib/Socket/chats.js +180 -89
- package/lib/Socket/community.js +169 -41
- package/lib/Socket/groups.js +25 -21
- package/lib/Socket/messages-recv.js +458 -333
- package/lib/Socket/messages-send.js +517 -572
- package/lib/Socket/mex.js +61 -0
- package/lib/Socket/newsletter.js +159 -252
- package/lib/Socket/socket.js +283 -100
- package/lib/Types/Newsletter.js +32 -25
- package/lib/Utils/auth-utils.js +189 -354
- package/lib/Utils/browser-utils.js +43 -0
- package/lib/Utils/chat-utils.js +166 -41
- package/lib/Utils/decode-wa-message.js +77 -35
- package/lib/Utils/event-buffer.js +80 -24
- package/lib/Utils/generics.js +28 -128
- package/lib/Utils/history.js +10 -8
- package/lib/Utils/index.js +1 -1
- package/lib/Utils/link-preview.js +17 -32
- package/lib/Utils/lt-hash.js +28 -22
- package/lib/Utils/make-mutex.js +26 -28
- package/lib/Utils/message-retry-manager.js +51 -3
- package/lib/Utils/messages-media.js +343 -151
- package/lib/Utils/messages.js +806 -792
- package/lib/Utils/noise-handler.js +33 -2
- package/lib/Utils/pre-key-manager.js +126 -0
- package/lib/Utils/process-message.js +115 -55
- package/lib/Utils/signal.js +45 -18
- package/lib/Utils/validate-connection.js +52 -29
- package/lib/WABinary/constants.js +1268 -1268
- package/lib/WABinary/decode.js +58 -4
- package/lib/WABinary/encode.js +54 -7
- package/lib/WABinary/jid-utils.js +58 -11
- package/lib/WAM/constants.js +19064 -11563
- package/lib/WAM/encode.js +57 -8
- package/lib/WAUSync/USyncQuery.js +35 -19
- package/package.json +9 -8
- package/lib/Socket/usync.js +0 -83
package/lib/Socket/community.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
5
|
const { proto } = require("../../WAProto")
|
|
6
|
-
const {
|
|
6
|
+
const { default: logger } = require("../Utils/logger")
|
|
7
|
+
const {
|
|
8
|
+
WAMessageStubType,
|
|
9
|
+
WAMessageAddressingMode
|
|
10
|
+
} = require("../Types")
|
|
7
11
|
const {
|
|
8
12
|
generateMessageID,
|
|
9
13
|
unixTimestampSeconds
|
|
@@ -19,7 +23,14 @@ const { makeBusinessSocket } = require("./business")
|
|
|
19
23
|
|
|
20
24
|
const makeCommunitiesSocket = (config) => {
|
|
21
25
|
const suki = makeBusinessSocket(config)
|
|
22
|
-
const {
|
|
26
|
+
const {
|
|
27
|
+
authState,
|
|
28
|
+
ev,
|
|
29
|
+
query,
|
|
30
|
+
groupMetadata,
|
|
31
|
+
upsertMessage,
|
|
32
|
+
cleanDirtyBits
|
|
33
|
+
} = suki
|
|
23
34
|
|
|
24
35
|
const communityQuery = async (jid, type, content) => (query({
|
|
25
36
|
tag: 'iq',
|
|
@@ -75,6 +86,28 @@ const makeCommunitiesSocket = (config) => {
|
|
|
75
86
|
return data
|
|
76
87
|
}
|
|
77
88
|
|
|
89
|
+
async function parseGroupResult(node) {
|
|
90
|
+
logger.info({ node }, 'parseGroupResult')
|
|
91
|
+
|
|
92
|
+
const groupNode = getBinaryNodeChild(node, 'group')
|
|
93
|
+
|
|
94
|
+
if (groupNode) {
|
|
95
|
+
try {
|
|
96
|
+
logger.info({ groupNode }, 'groupNode')
|
|
97
|
+
|
|
98
|
+
const metadata = await groupMetadata(`${groupNode.attrs.id}@g.us`)
|
|
99
|
+
|
|
100
|
+
return metadata ? metadata : null
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
logger.warn({ error }, 'Error parsing group metadata')
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return null
|
|
109
|
+
}
|
|
110
|
+
|
|
78
111
|
suki.ws.on('CB:ib,,dirty', async (node) => {
|
|
79
112
|
const { attrs } = getBinaryNodeChild(node, 'dirty')
|
|
80
113
|
|
|
@@ -83,7 +116,7 @@ const makeCommunitiesSocket = (config) => {
|
|
|
83
116
|
}
|
|
84
117
|
|
|
85
118
|
await communityFetchAllParticipating()
|
|
86
|
-
await
|
|
119
|
+
await cleanDirtyBits('groups')
|
|
87
120
|
})
|
|
88
121
|
|
|
89
122
|
return {
|
|
@@ -125,7 +158,28 @@ const makeCommunitiesSocket = (config) => {
|
|
|
125
158
|
}
|
|
126
159
|
])
|
|
127
160
|
|
|
128
|
-
return
|
|
161
|
+
return await parseGroupResult(result)
|
|
162
|
+
},
|
|
163
|
+
communityCreateGroup: async (subject, participants, parentCommunityJid) => {
|
|
164
|
+
const key = generateMessageID()
|
|
165
|
+
const result = await communityQuery('@g.us', 'set', [
|
|
166
|
+
{
|
|
167
|
+
tag: 'create',
|
|
168
|
+
attrs: {
|
|
169
|
+
subject,
|
|
170
|
+
key
|
|
171
|
+
},
|
|
172
|
+
content: [
|
|
173
|
+
...participants.map(jid => ({
|
|
174
|
+
tag: 'participant',
|
|
175
|
+
attrs: { jid }
|
|
176
|
+
})),
|
|
177
|
+
{ tag: 'linked_parent', attrs: { jid: parentCommunityJid } }
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
])
|
|
181
|
+
|
|
182
|
+
return await parseGroupResult(result)
|
|
129
183
|
},
|
|
130
184
|
communityLeave: async (id) => {
|
|
131
185
|
await communityQuery('@g.us', 'set', [
|
|
@@ -147,6 +201,72 @@ const makeCommunitiesSocket = (config) => {
|
|
|
147
201
|
}
|
|
148
202
|
])
|
|
149
203
|
},
|
|
204
|
+
communityLinkGroup: async (groupJid, parentCommunityJid) => {
|
|
205
|
+
await communityQuery(parentCommunityJid, 'set', [
|
|
206
|
+
{
|
|
207
|
+
tag: 'links',
|
|
208
|
+
attrs: {},
|
|
209
|
+
content: [
|
|
210
|
+
{
|
|
211
|
+
tag: 'link',
|
|
212
|
+
attrs: { link_type: 'sub_group' },
|
|
213
|
+
content: [{ tag: 'group', attrs: { jid: groupJid } }]
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
])
|
|
218
|
+
},
|
|
219
|
+
communityUnlinkGroup: async (groupJid, parentCommunityJid) => {
|
|
220
|
+
await communityQuery(parentCommunityJid, 'set', [
|
|
221
|
+
{
|
|
222
|
+
tag: 'unlink',
|
|
223
|
+
attrs: { unlink_type: 'sub_group' },
|
|
224
|
+
content: [{ tag: 'group', attrs: { jid: groupJid } }]
|
|
225
|
+
}
|
|
226
|
+
])
|
|
227
|
+
},
|
|
228
|
+
communityFetchLinkedGroups: async (jid) => {
|
|
229
|
+
let communityJid = jid
|
|
230
|
+
let isCommunity = false
|
|
231
|
+
|
|
232
|
+
// Try to determine if it is a subgroup or a community
|
|
233
|
+
const metadata = await groupMetadata(jid)
|
|
234
|
+
|
|
235
|
+
if (metadata.linkedParent) {
|
|
236
|
+
// It is a subgroup, get the community jid
|
|
237
|
+
communityJid = metadata.linkedParent
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
else {
|
|
241
|
+
// It is a community
|
|
242
|
+
isCommunity = true
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Fetch all subgroups of the community
|
|
246
|
+
const result = await communityQuery(communityJid, 'get', [{ tag: 'sub_groups', attrs: {} }])
|
|
247
|
+
const linkedGroupsData = []
|
|
248
|
+
const subGroupsNode = getBinaryNodeChild(result, 'sub_groups')
|
|
249
|
+
|
|
250
|
+
if (subGroupsNode) {
|
|
251
|
+
const groupNodes = getBinaryNodeChildren(subGroupsNode, 'group')
|
|
252
|
+
|
|
253
|
+
for (const groupNode of groupNodes) {
|
|
254
|
+
linkedGroupsData.push({
|
|
255
|
+
id: groupNode.attrs.id ? jidEncode(groupNode.attrs.id, 'g.us') : undefined,
|
|
256
|
+
subject: groupNode.attrs.subject || '',
|
|
257
|
+
creation: groupNode.attrs.creation ? Number(groupNode.attrs.creation) : undefined,
|
|
258
|
+
owner: groupNode.attrs.creator ? jidNormalizedUser(groupNode.attrs.creator) : undefined,
|
|
259
|
+
size: groupNode.attrs.size ? Number(groupNode.attrs.size) : undefined
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
communityJid,
|
|
266
|
+
isCommunity,
|
|
267
|
+
linkedGroups: linkedGroupsData
|
|
268
|
+
}
|
|
269
|
+
},
|
|
150
270
|
communityRequestParticipantsList: async (jid) => {
|
|
151
271
|
const result = await communityQuery(jid, 'get', [
|
|
152
272
|
{
|
|
@@ -161,7 +281,8 @@ const makeCommunitiesSocket = (config) => {
|
|
|
161
281
|
return participants.map(v => v.attrs)
|
|
162
282
|
},
|
|
163
283
|
communityRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
164
|
-
const result = await communityQuery(jid, 'set', [
|
|
284
|
+
const result = await communityQuery(jid, 'set', [
|
|
285
|
+
{
|
|
165
286
|
tag: 'membership_requests_action',
|
|
166
287
|
attrs: {},
|
|
167
288
|
content: [
|
|
@@ -174,8 +295,9 @@ const makeCommunitiesSocket = (config) => {
|
|
|
174
295
|
}))
|
|
175
296
|
}
|
|
176
297
|
]
|
|
177
|
-
}
|
|
178
|
-
|
|
298
|
+
}
|
|
299
|
+
])
|
|
300
|
+
|
|
179
301
|
const node = getBinaryNodeChild(result, 'membership_requests_action')
|
|
180
302
|
const nodeAction = getBinaryNodeChild(node, action)
|
|
181
303
|
const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant')
|
|
@@ -188,13 +310,14 @@ const makeCommunitiesSocket = (config) => {
|
|
|
188
310
|
const result = await communityQuery(jid, 'set', [
|
|
189
311
|
{
|
|
190
312
|
tag: action,
|
|
191
|
-
attrs: {},
|
|
313
|
+
attrs: action === 'remove' ? { linked_groups: 'true' } : {},
|
|
192
314
|
content: participants.map(jid => ({
|
|
193
315
|
tag: 'participant',
|
|
194
316
|
attrs: { jid }
|
|
195
317
|
}))
|
|
196
318
|
}
|
|
197
319
|
])
|
|
320
|
+
|
|
198
321
|
const node = getBinaryNodeChild(result, action)
|
|
199
322
|
const participantsAffected = getBinaryNodeChildren(node, 'participant')
|
|
200
323
|
|
|
@@ -204,8 +327,7 @@ const makeCommunitiesSocket = (config) => {
|
|
|
204
327
|
},
|
|
205
328
|
communityUpdateDescription: async (jid, description) => {
|
|
206
329
|
const metadata = await communityMetadata(jid)
|
|
207
|
-
const prev = metadata.descId
|
|
208
|
-
|
|
330
|
+
const prev = metadata.descId ?? null
|
|
209
331
|
await communityQuery(jid, 'set', [
|
|
210
332
|
{
|
|
211
333
|
tag: 'description',
|
|
@@ -213,9 +335,7 @@ const makeCommunitiesSocket = (config) => {
|
|
|
213
335
|
...(description ? { id: generateMessageID() } : { delete: 'true' }),
|
|
214
336
|
...(prev ? { prev } : {})
|
|
215
337
|
},
|
|
216
|
-
content: description ? [
|
|
217
|
-
{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
|
|
218
|
-
] : undefined
|
|
338
|
+
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
219
339
|
}
|
|
220
340
|
])
|
|
221
341
|
},
|
|
@@ -223,19 +343,19 @@ const makeCommunitiesSocket = (config) => {
|
|
|
223
343
|
const result = await communityQuery(jid, 'get', [{ tag: 'invite', attrs: {} }])
|
|
224
344
|
const inviteNode = getBinaryNodeChild(result, 'invite')
|
|
225
345
|
|
|
226
|
-
return inviteNode?.attrs
|
|
346
|
+
return inviteNode?.attrs.code
|
|
227
347
|
},
|
|
228
348
|
communityRevokeInvite: async (jid) => {
|
|
229
349
|
const result = await communityQuery(jid, 'set', [{ tag: 'invite', attrs: {} }])
|
|
230
350
|
const inviteNode = getBinaryNodeChild(result, 'invite')
|
|
231
351
|
|
|
232
|
-
return inviteNode?.attrs
|
|
352
|
+
return inviteNode?.attrs.code
|
|
233
353
|
},
|
|
234
354
|
communityAcceptInvite: async (code) => {
|
|
235
355
|
const results = await communityQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }])
|
|
236
356
|
const result = getBinaryNodeChild(results, 'community')
|
|
237
357
|
|
|
238
|
-
return result?.attrs
|
|
358
|
+
return result?.attrs.jid
|
|
239
359
|
},
|
|
240
360
|
/**
|
|
241
361
|
* revoke a v4 invite for someone
|
|
@@ -244,26 +364,31 @@ const makeCommunitiesSocket = (config) => {
|
|
|
244
364
|
* @returns true if successful
|
|
245
365
|
*/
|
|
246
366
|
communityRevokeInviteV4: async (communityJid, invitedJid) => {
|
|
247
|
-
const result = await communityQuery(communityJid, 'set', [
|
|
367
|
+
const result = await communityQuery(communityJid, 'set', [
|
|
368
|
+
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
369
|
+
])
|
|
248
370
|
|
|
249
371
|
return !!result
|
|
250
372
|
},
|
|
251
373
|
/**
|
|
252
|
-
* accept a
|
|
374
|
+
* accept a CommunityInviteMessage
|
|
253
375
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
254
376
|
* @param inviteMessage the message to accept
|
|
255
377
|
*/
|
|
256
378
|
communityAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
257
379
|
key = typeof key === 'string' ? { remoteJid: key } : key
|
|
258
|
-
|
|
380
|
+
|
|
381
|
+
const results = await communityQuery(inviteMessage.groupJid, 'set', [
|
|
382
|
+
{
|
|
259
383
|
tag: 'accept',
|
|
260
384
|
attrs: {
|
|
261
385
|
code: inviteMessage.inviteCode,
|
|
262
386
|
expiration: inviteMessage.inviteExpiration.toString(),
|
|
263
387
|
admin: key.remoteJid
|
|
264
388
|
}
|
|
265
|
-
}
|
|
266
|
-
|
|
389
|
+
}
|
|
390
|
+
])
|
|
391
|
+
|
|
267
392
|
// if we have the full message key
|
|
268
393
|
// update the invite message to be expired
|
|
269
394
|
if (key.id) {
|
|
@@ -283,18 +408,16 @@ const makeCommunitiesSocket = (config) => {
|
|
|
283
408
|
])
|
|
284
409
|
}
|
|
285
410
|
|
|
286
|
-
// generate the
|
|
411
|
+
// generate the community add message
|
|
287
412
|
await upsertMessage({
|
|
288
413
|
key: {
|
|
289
414
|
remoteJid: inviteMessage.groupJid,
|
|
290
|
-
id: generateMessageID(
|
|
415
|
+
id: generateMessageID(suki.user?.id),
|
|
291
416
|
fromMe: false,
|
|
292
|
-
participant: key.remoteJid
|
|
417
|
+
participant: key.remoteJid // TODO: investigate if this makes any sense at all
|
|
293
418
|
},
|
|
294
419
|
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
295
|
-
messageStubParameters: [
|
|
296
|
-
authState.creds.me.id
|
|
297
|
-
],
|
|
420
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
298
421
|
participant: key.remoteJid,
|
|
299
422
|
messageTimestamp: unixTimestampSeconds()
|
|
300
423
|
}, 'notify')
|
|
@@ -303,13 +426,13 @@ const makeCommunitiesSocket = (config) => {
|
|
|
303
426
|
}),
|
|
304
427
|
communityGetInviteInfo: async (code) => {
|
|
305
428
|
const results = await communityQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }])
|
|
306
|
-
|
|
307
429
|
return extractCommunityMetadata(results)
|
|
308
430
|
},
|
|
309
431
|
communityToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
310
|
-
const content = ephemeralExpiration
|
|
311
|
-
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
312
|
-
{ tag: 'not_ephemeral', attrs: {} }
|
|
432
|
+
const content = ephemeralExpiration
|
|
433
|
+
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
434
|
+
: { tag: 'not_ephemeral', attrs: {} }
|
|
435
|
+
|
|
313
436
|
await communityQuery(jid, 'set', [content])
|
|
314
437
|
},
|
|
315
438
|
communitySettingUpdate: async (jid, setting) => {
|
|
@@ -319,7 +442,9 @@ const makeCommunitiesSocket = (config) => {
|
|
|
319
442
|
await communityQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }])
|
|
320
443
|
},
|
|
321
444
|
communityJoinApprovalMode: async (jid, mode) => {
|
|
322
|
-
await communityQuery(jid, 'set', [
|
|
445
|
+
await communityQuery(jid, 'set', [
|
|
446
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'community_join', attrs: { state: mode } }] }
|
|
447
|
+
])
|
|
323
448
|
},
|
|
324
449
|
communityFetchAllParticipating
|
|
325
450
|
}
|
|
@@ -344,13 +469,15 @@ const extractCommunityMetadata = (result) => {
|
|
|
344
469
|
|
|
345
470
|
const metadata = {
|
|
346
471
|
id: communityId,
|
|
347
|
-
addressingMode: mode,
|
|
348
472
|
subject: community.attrs.subject,
|
|
349
|
-
subjectOwner:
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
473
|
+
subjectOwner: community.attrs.s_o,
|
|
474
|
+
subjectOwnerAlt: community.attrs?.s_o_pn ? community.attrs.s_o_pn : community.attrs.s_o,
|
|
475
|
+
subjectTime: Number(community.attrs.s_t || 0),
|
|
476
|
+
size: Number(community.attrs?.size ? community.attrs.size : getBinaryNodeChildren(community, 'participant').length),
|
|
477
|
+
creation: Number(community.attrs.creation || 0),
|
|
478
|
+
owner: community.attrs.creator ? jidNormalizedUser(community.attrs.creator) : undefined,
|
|
479
|
+
ownerAlt: community.attrs.creator ? jidNormalizedUser(community.attrs?.creator_pn ? community.attrs.creator_pn : community.attrs.creator) : undefined,
|
|
480
|
+
ownerCountry: community.attrs.creator_country_code,
|
|
354
481
|
desc,
|
|
355
482
|
descId,
|
|
356
483
|
linkedParent: getBinaryNodeChild(community, 'linked_parent')?.attrs.jid || undefined,
|
|
@@ -362,12 +489,13 @@ const extractCommunityMetadata = (result) => {
|
|
|
362
489
|
memberAddMode,
|
|
363
490
|
participants: getBinaryNodeChildren(community, 'participant').map(({ attrs }) => {
|
|
364
491
|
return {
|
|
365
|
-
id: mode ===
|
|
366
|
-
lid: mode ===
|
|
492
|
+
id: mode === WAMessageAddressingMode.LID ? community.phone_number : attrs.jid,
|
|
493
|
+
lid: mode === WAMessageAddressingMode.LID ? community.jid : attrs.lid,
|
|
367
494
|
admin: (attrs.type || null),
|
|
368
495
|
}
|
|
369
496
|
}),
|
|
370
|
-
ephemeralDuration: eph ?
|
|
497
|
+
ephemeralDuration: eph ? Number(ph) : undefined,
|
|
498
|
+
addressingMode: mode
|
|
371
499
|
}
|
|
372
500
|
|
|
373
501
|
return metadata
|
package/lib/Socket/groups.js
CHANGED
|
@@ -21,7 +21,13 @@ const { makeChatsSocket } = require("./chats")
|
|
|
21
21
|
|
|
22
22
|
const makeGroupsSocket = (config) => {
|
|
23
23
|
const suki = makeChatsSocket(config)
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
authState,
|
|
26
|
+
ev,
|
|
27
|
+
query,
|
|
28
|
+
cleanDirtyBits,
|
|
29
|
+
upsertMessage
|
|
30
|
+
} = suki
|
|
25
31
|
|
|
26
32
|
const groupQuery = async (jid, type, content) => (query({
|
|
27
33
|
tag: 'iq',
|
|
@@ -84,7 +90,7 @@ const makeGroupsSocket = (config) => {
|
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
await groupFetchAllParticipating()
|
|
87
|
-
await
|
|
93
|
+
await cleanDirtyBits('groups')
|
|
88
94
|
})
|
|
89
95
|
|
|
90
96
|
return {
|
|
@@ -270,14 +276,12 @@ const makeGroupsSocket = (config) => {
|
|
|
270
276
|
await upsertMessage({
|
|
271
277
|
key: {
|
|
272
278
|
remoteJid: inviteMessage.groupJid,
|
|
273
|
-
id: generateMessageID(
|
|
279
|
+
id: generateMessageID(suki.user?.id),
|
|
274
280
|
fromMe: false,
|
|
275
|
-
participant: key.remoteJid
|
|
281
|
+
participant: key.remoteJid
|
|
276
282
|
},
|
|
277
283
|
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
278
|
-
messageStubParameters: [
|
|
279
|
-
authState.creds.me.id
|
|
280
|
-
],
|
|
284
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
281
285
|
participant: key.remoteJid,
|
|
282
286
|
messageTimestamp: unixTimestampSeconds()
|
|
283
287
|
}, 'notify')
|
|
@@ -311,18 +315,18 @@ const makeGroupsSocket = (config) => {
|
|
|
311
315
|
const extractGroupMetadata = (result) => {
|
|
312
316
|
const group = getBinaryNodeChild(result, 'group')
|
|
313
317
|
const descChild = getBinaryNodeChild(group, 'description')
|
|
314
|
-
const mode = group.attrs.addressing_mode ===
|
|
318
|
+
const mode = group.attrs.addressing_mode === WAMessageAddressingMode.LID ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN
|
|
315
319
|
|
|
316
320
|
let desc
|
|
317
321
|
let descId
|
|
318
322
|
let descOwner
|
|
319
|
-
let
|
|
323
|
+
let descOwnerAlt
|
|
320
324
|
|
|
321
325
|
if (descChild) {
|
|
322
326
|
desc = getBinaryNodeChildString(descChild, 'body')
|
|
323
327
|
descId = descChild.attrs.id
|
|
324
328
|
descOwner = mode === WAMessageAddressingMode.LID ? jidNormalizedUser(descChild.attrs.participant_pn) : jidNormalizedUser(descChild.attrs.participant)
|
|
325
|
-
|
|
329
|
+
descOwnerAlt = mode === WAMessageAddressingMode.LID ? jidNormalizedUser(descChild.attrs.participant) : undefined
|
|
326
330
|
}
|
|
327
331
|
|
|
328
332
|
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us')
|
|
@@ -331,20 +335,19 @@ const extractGroupMetadata = (result) => {
|
|
|
331
335
|
|
|
332
336
|
const metadata = {
|
|
333
337
|
id: groupId,
|
|
334
|
-
addressingMode: mode,
|
|
335
338
|
subject: group.attrs.subject,
|
|
336
|
-
subjectOwner:
|
|
337
|
-
|
|
338
|
-
subjectTime:
|
|
339
|
-
size: group.attrs?.size ?
|
|
340
|
-
creation:
|
|
341
|
-
owner: group.attrs.creator ? jidNormalizedUser(
|
|
342
|
-
|
|
339
|
+
subjectOwner: group.attrs.s_o,
|
|
340
|
+
subjectOwnerAlt: group.attrs?.s_o_pn ? group.attrs.s_o_pn : group.attrs.s_o,
|
|
341
|
+
subjectTime: Number(group.attrs.s_t),
|
|
342
|
+
size: Number(group.attrs?.size ? group.attrs.size : getBinaryNodeChildren(group, 'participant').length),
|
|
343
|
+
creation: Number(group.attrs.creation),
|
|
344
|
+
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
|
345
|
+
ownerAlt: group.attrs.creator ? jidNormalizedUser(group.attrs?.creator_pn ? group.attrs.creator_pn : group.attrs.creator_pn) : undefined,
|
|
343
346
|
ownerCountry: group.attrs.creator_country_code,
|
|
344
347
|
desc,
|
|
345
348
|
descId,
|
|
346
349
|
descOwner,
|
|
347
|
-
|
|
350
|
+
descOwnerAlt,
|
|
348
351
|
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
|
349
352
|
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
350
353
|
announce: !!getBinaryNodeChild(group, 'announcement'),
|
|
@@ -356,10 +359,11 @@ const extractGroupMetadata = (result) => {
|
|
|
356
359
|
return {
|
|
357
360
|
id: mode === WAMessageAddressingMode.LID ? attrs.phone_number : attrs.jid,
|
|
358
361
|
lid: mode === WAMessageAddressingMode.LID ? attrs.jid : attrs.lid,
|
|
359
|
-
admin: (attrs.type || null)
|
|
362
|
+
admin: (attrs.type || null)
|
|
360
363
|
}
|
|
361
364
|
}),
|
|
362
|
-
ephemeralDuration: eph ?
|
|
365
|
+
ephemeralDuration: eph ? Number(eph) : undefined,
|
|
366
|
+
addressingMode: mode
|
|
363
367
|
}
|
|
364
368
|
|
|
365
369
|
return metadata
|