@hansaka02/baileys 7.3.2 → 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/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/connection.js +51 -0
- package/lib/Defaults/constants.js +74 -0
- package/lib/Defaults/history.js +19 -0
- package/lib/Defaults/index.js +36 -142
- package/lib/Defaults/media.js +48 -0
- package/lib/Defaults/prefix.js +18 -0
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +9 -6
- package/lib/Signal/Group/index.js +39 -53
- package/lib/Signal/Group/keyhelper.js +8 -41
- package/lib/Signal/Group/sender-chain-key.js +5 -18
- package/lib/Signal/Group/sender-key-distribution-message.js +7 -7
- package/lib/Signal/Group/sender-key-message.js +12 -8
- package/lib/Signal/Group/sender-key-record.js +7 -16
- package/lib/Signal/Group/sender-key-state.js +15 -61
- package/lib/Signal/Group/sender-message-key.js +2 -2
- package/lib/Signal/libsignal.js +237 -177
- package/lib/Signal/lid-mapping.js +128 -71
- package/lib/Socket/Client/types.js +2 -2
- package/lib/Socket/Client/websocket.js +25 -16
- package/lib/Socket/business.js +46 -33
- package/lib/Socket/chats.js +286 -170
- package/lib/Socket/community.js +215 -77
- package/lib/Socket/groups.js +77 -61
- package/lib/Socket/index.js +4 -4
- package/lib/Socket/messages-recv.js +629 -457
- package/lib/Socket/messages-send.js +645 -656
- package/lib/Socket/mex.js +61 -0
- package/lib/Socket/newsletter.js +166 -245
- package/lib/Socket/socket.js +396 -170
- package/lib/Store/index.js +27 -11
- package/lib/Store/make-cache-manager-store.js +14 -15
- package/lib/Store/make-in-memory-store.js +28 -24
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +6 -6
- package/lib/Types/MexUpdates.js +5 -5
- package/lib/Types/Newsletter.js +32 -25
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +28 -12
- package/lib/Utils/auth-utils.js +212 -375
- package/lib/Utils/baileys-event-stream.js +68 -69
- package/lib/Utils/browser-utils.js +43 -0
- package/lib/Utils/business.js +63 -53
- package/lib/Utils/chat-utils.js +241 -106
- package/lib/Utils/crypto.js +25 -45
- package/lib/Utils/decode-wa-message.js +361 -311
- package/lib/Utils/event-buffer.js +97 -42
- package/lib/Utils/generics.js +90 -207
- package/lib/Utils/history.js +29 -27
- package/lib/Utils/index.js +28 -14
- package/lib/Utils/link-preview.js +24 -62
- package/lib/Utils/logger.js +5 -5
- package/lib/Utils/lt-hash.js +29 -23
- package/lib/Utils/make-mutex.js +26 -28
- package/lib/Utils/message-retry-manager.js +55 -7
- package/lib/Utils/messages-media.js +434 -247
- package/lib/Utils/messages.js +963 -917
- package/lib/Utils/noise-handler.js +60 -20
- package/lib/Utils/pre-key-manager.js +126 -0
- package/lib/Utils/process-message.js +216 -141
- package/lib/Utils/signal.js +75 -37
- package/lib/Utils/use-multi-file-auth-state.js +18 -22
- package/lib/Utils/validate-connection.js +96 -66
- package/lib/WABinary/constants.js +1268 -1268
- package/lib/WABinary/decode.js +62 -34
- package/lib/WABinary/encode.js +57 -36
- package/lib/WABinary/generic-utils.js +4 -4
- package/lib/WABinary/index.js +27 -11
- package/lib/WABinary/jid-utils.js +58 -11
- package/lib/WAM/constants.js +19064 -11563
- package/lib/WAM/encode.js +71 -14
- package/lib/WAM/index.js +27 -11
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/index.js +27 -11
- package/lib/WAUSync/USyncQuery.js +51 -28
- package/lib/WAUSync/index.js +27 -11
- package/lib/index.js +60 -31
- package/package.json +12 -17
- package/WAProto/AICommon/AICommon.d.ts +0 -11702
- package/WAProto/Adv/Adv.d.ts +0 -643
- package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
- package/WAProto/Cert/Cert.d.ts +0 -613
- package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
- package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
- package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
- package/WAProto/E2E/E2E.d.ts +0 -41724
- package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
- package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
- package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
- package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
- package/WAProto/Protocol/Protocol.d.ts +0 -270
- package/WAProto/Reporting/Reporting.d.ts +0 -371
- package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
- package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
- package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
- package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
- package/WAProto/UserPassword/UserPassword.d.ts +0 -363
- package/WAProto/VnameCert/VnameCert.d.ts +0 -821
- package/WAProto/Wa6/Wa6.d.ts +0 -2128
- package/WAProto/Web/Web.d.ts +0 -46383
- package/WAProto/index.d.ts +0 -55
- package/lib/Defaults/index.d.ts +0 -77
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts +0 -19
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -16
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-name.d.ts +0 -19
- package/lib/Signal/Group/sender-key-record.d.ts +0 -32
- package/lib/Signal/Group/sender-key-state.d.ts +0 -44
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -8
- package/lib/Signal/lid-mapping.d.ts +0 -28
- package/lib/Socket/Client/index.d.ts +0 -2
- package/lib/Socket/Client/types.d.ts +0 -16
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Socket/business.d.ts +0 -187
- package/lib/Socket/chats.d.ts +0 -97
- package/lib/Socket/community.d.ts +0 -129
- package/lib/Socket/groups.d.ts +0 -129
- package/lib/Socket/index.d.ts +0 -191
- package/lib/Socket/messages-recv.d.ts +0 -174
- package/lib/Socket/messages-send.d.ts +0 -165
- package/lib/Socket/newsletter.d.ts +0 -145
- package/lib/Socket/socket.d.ts +0 -45
- package/lib/Socket/usync.d.ts +0 -37
- package/lib/Socket/usync.js +0 -83
- package/lib/Store/index.d.ts +0 -4
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-in-memory-store.d.ts +0 -123
- package/lib/Store/make-ordered-dictionary.d.ts +0 -12
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -121
- package/lib/Types/Bussiness.d.ts +0 -28
- package/lib/Types/Call.d.ts +0 -14
- package/lib/Types/Chat.d.ts +0 -143
- package/lib/Types/Contact.d.ts +0 -23
- package/lib/Types/Events.d.ts +0 -226
- package/lib/Types/GroupMetadata.d.ts +0 -66
- package/lib/Types/Label.d.ts +0 -48
- package/lib/Types/LabelAssociation.d.ts +0 -35
- package/lib/Types/Message.d.ts +0 -484
- package/lib/Types/MexUpdates.d.ts +0 -9
- package/lib/Types/Newsletter.d.ts +0 -109
- package/lib/Types/Product.d.ts +0 -92
- package/lib/Types/Signal.d.ts +0 -98
- package/lib/Types/Socket.d.ts +0 -141
- package/lib/Types/State.d.ts +0 -41
- package/lib/Types/USync.d.ts +0 -26
- package/lib/Types/index.d.ts +0 -80
- package/lib/Utils/auth-utils.d.ts +0 -21
- package/lib/Utils/baileys-event-stream.d.ts +0 -18
- package/lib/Utils/business.d.ts +0 -29
- package/lib/Utils/chat-utils.d.ts +0 -82
- package/lib/Utils/crypto.d.ts +0 -56
- package/lib/Utils/decode-wa-message.d.ts +0 -53
- package/lib/Utils/event-buffer.d.ts +0 -39
- package/lib/Utils/generics.d.ts +0 -117
- package/lib/Utils/history.d.ts +0 -23
- package/lib/Utils/index.d.ts +0 -20
- package/lib/Utils/link-preview.d.ts +0 -23
- package/lib/Utils/logger.d.ts +0 -13
- package/lib/Utils/lt-hash.d.ts +0 -14
- package/lib/Utils/make-mutex.d.ts +0 -9
- package/lib/Utils/message-retry-manager.d.ts +0 -88
- package/lib/Utils/messages-media.d.ts +0 -135
- package/lib/Utils/messages.d.ts +0 -105
- package/lib/Utils/noise-handler.d.ts +0 -20
- package/lib/Utils/process-message.d.ts +0 -49
- package/lib/Utils/signal.d.ts +0 -42
- package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
- package/lib/Utils/use-mongo-file-auth-state.js +0 -84
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
- package/lib/Utils/use-single-file-auth-state.js +0 -80
- package/lib/Utils/validate-connection.d.ts +0 -13
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -9
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -28
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -58
- package/lib/WABinary/types.d.ts +0 -22
- package/lib/WAM/BinaryInfo.d.ts +0 -16
- package/lib/WAM/constants.d.ts +0 -47
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
- package/lib/WAUSync/Protocols/index.d.ts +0 -6
- package/lib/WAUSync/USyncQuery.d.ts +0 -31
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -13
package/lib/Socket/groups.js
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const { proto } = require("../../WAProto")
|
|
5
|
+
const {
|
|
6
|
+
WAMessageStubType,
|
|
7
|
+
WAMessageAddressingMode
|
|
8
|
+
} = require("../Types")
|
|
9
|
+
const {
|
|
10
|
+
generateMessageID,
|
|
11
|
+
unixTimestampSeconds
|
|
12
|
+
} = require("../Utils")
|
|
13
|
+
const {
|
|
14
|
+
getBinaryNodeChild,
|
|
15
|
+
getBinaryNodeChildren,
|
|
16
|
+
getBinaryNodeChildString,
|
|
17
|
+
jidEncode,
|
|
18
|
+
jidNormalizedUser
|
|
19
|
+
} = require("../WABinary")
|
|
20
|
+
const { makeChatsSocket } = require("./chats")
|
|
9
21
|
|
|
10
22
|
const makeGroupsSocket = (config) => {
|
|
11
|
-
const suki =
|
|
12
|
-
const {
|
|
23
|
+
const suki = makeChatsSocket(config)
|
|
24
|
+
const {
|
|
25
|
+
authState,
|
|
26
|
+
ev,
|
|
27
|
+
query,
|
|
28
|
+
cleanDirtyBits,
|
|
29
|
+
upsertMessage
|
|
30
|
+
} = suki
|
|
13
31
|
|
|
14
32
|
const groupQuery = async (jid, type, content) => (query({
|
|
15
33
|
tag: 'iq',
|
|
@@ -47,10 +65,10 @@ const makeGroupsSocket = (config) => {
|
|
|
47
65
|
})
|
|
48
66
|
|
|
49
67
|
const data = {}
|
|
50
|
-
const groupsChild =
|
|
68
|
+
const groupsChild = getBinaryNodeChild(result, 'groups')
|
|
51
69
|
|
|
52
70
|
if (groupsChild) {
|
|
53
|
-
const groups =
|
|
71
|
+
const groups = getBinaryNodeChildren(groupsChild, 'group')
|
|
54
72
|
for (const groupNode of groups) {
|
|
55
73
|
const meta = extractGroupMetadata({
|
|
56
74
|
tag: 'result',
|
|
@@ -66,13 +84,13 @@ const makeGroupsSocket = (config) => {
|
|
|
66
84
|
}
|
|
67
85
|
|
|
68
86
|
suki.ws.on('CB:ib,,dirty', async (node) => {
|
|
69
|
-
const { attrs } =
|
|
87
|
+
const { attrs } = getBinaryNodeChild(node, 'dirty')
|
|
70
88
|
if (attrs.type !== 'groups') {
|
|
71
89
|
return
|
|
72
90
|
}
|
|
73
91
|
|
|
74
92
|
await groupFetchAllParticipating()
|
|
75
|
-
await
|
|
93
|
+
await cleanDirtyBits('groups')
|
|
76
94
|
})
|
|
77
95
|
|
|
78
96
|
return {
|
|
@@ -80,7 +98,7 @@ const makeGroupsSocket = (config) => {
|
|
|
80
98
|
groupQuery,
|
|
81
99
|
groupMetadata,
|
|
82
100
|
groupCreate: async (subject, participants) => {
|
|
83
|
-
const key =
|
|
101
|
+
const key = generateMessageID()
|
|
84
102
|
|
|
85
103
|
const result = await groupQuery('@g.us', 'set', [
|
|
86
104
|
{
|
|
@@ -126,8 +144,8 @@ const makeGroupsSocket = (config) => {
|
|
|
126
144
|
}
|
|
127
145
|
])
|
|
128
146
|
|
|
129
|
-
const node =
|
|
130
|
-
const participants =
|
|
147
|
+
const node = getBinaryNodeChild(result, 'membership_approval_requests')
|
|
148
|
+
const participants = getBinaryNodeChildren(node, 'membership_approval_request')
|
|
131
149
|
|
|
132
150
|
return participants.map(v => v.attrs)
|
|
133
151
|
},
|
|
@@ -147,9 +165,9 @@ const makeGroupsSocket = (config) => {
|
|
|
147
165
|
]
|
|
148
166
|
}])
|
|
149
167
|
|
|
150
|
-
const node =
|
|
151
|
-
const nodeAction =
|
|
152
|
-
const participantsAffected =
|
|
168
|
+
const node = getBinaryNodeChild(result, 'membership_requests_action')
|
|
169
|
+
const nodeAction = getBinaryNodeChild(node, action)
|
|
170
|
+
const participantsAffected = getBinaryNodeChildren(nodeAction, 'participant')
|
|
153
171
|
|
|
154
172
|
return participantsAffected.map(p => {
|
|
155
173
|
return { status: p.attrs.error || '200', jid: p.attrs.jid }
|
|
@@ -166,8 +184,8 @@ const makeGroupsSocket = (config) => {
|
|
|
166
184
|
}))
|
|
167
185
|
}
|
|
168
186
|
])
|
|
169
|
-
const node =
|
|
170
|
-
const participantsAffected =
|
|
187
|
+
const node = getBinaryNodeChild(result, action)
|
|
188
|
+
const participantsAffected = getBinaryNodeChildren(node, 'participant')
|
|
171
189
|
|
|
172
190
|
return participantsAffected.map(p => {
|
|
173
191
|
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p }
|
|
@@ -181,7 +199,7 @@ const makeGroupsSocket = (config) => {
|
|
|
181
199
|
{
|
|
182
200
|
tag: 'description',
|
|
183
201
|
attrs: {
|
|
184
|
-
...(description ? { id:
|
|
202
|
+
...(description ? { id: generateMessageID() } : { delete: 'true' }),
|
|
185
203
|
...(prev ? { prev } : {})
|
|
186
204
|
},
|
|
187
205
|
content: description ? [
|
|
@@ -192,19 +210,19 @@ const makeGroupsSocket = (config) => {
|
|
|
192
210
|
},
|
|
193
211
|
groupInviteCode: async (jid) => {
|
|
194
212
|
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }])
|
|
195
|
-
const inviteNode =
|
|
213
|
+
const inviteNode = getBinaryNodeChild(result, 'invite')
|
|
196
214
|
|
|
197
215
|
return inviteNode?.attrs?.code
|
|
198
216
|
},
|
|
199
217
|
groupRevokeInvite: async (jid) => {
|
|
200
218
|
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }])
|
|
201
|
-
const inviteNode =
|
|
219
|
+
const inviteNode = getBinaryNodeChild(result, 'invite')
|
|
202
220
|
|
|
203
221
|
return inviteNode?.attrs?.code
|
|
204
222
|
},
|
|
205
223
|
groupAcceptInvite: async (code) => {
|
|
206
224
|
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }])
|
|
207
|
-
const result =
|
|
225
|
+
const result = getBinaryNodeChild(results, 'group')
|
|
208
226
|
|
|
209
227
|
return result?.attrs?.jid
|
|
210
228
|
},
|
|
@@ -239,7 +257,7 @@ const makeGroupsSocket = (config) => {
|
|
|
239
257
|
// update the invite message to be expired
|
|
240
258
|
if (key.id) {
|
|
241
259
|
// create new invite message that is expired
|
|
242
|
-
inviteMessage =
|
|
260
|
+
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage)
|
|
243
261
|
inviteMessage.inviteExpiration = 0
|
|
244
262
|
inviteMessage.inviteCode = ''
|
|
245
263
|
ev.emit('messages.update', [
|
|
@@ -258,16 +276,14 @@ const makeGroupsSocket = (config) => {
|
|
|
258
276
|
await upsertMessage({
|
|
259
277
|
key: {
|
|
260
278
|
remoteJid: inviteMessage.groupJid,
|
|
261
|
-
id:
|
|
279
|
+
id: generateMessageID(suki.user?.id),
|
|
262
280
|
fromMe: false,
|
|
263
|
-
participant: key.remoteJid
|
|
281
|
+
participant: key.remoteJid
|
|
264
282
|
},
|
|
265
|
-
messageStubType:
|
|
266
|
-
messageStubParameters: [
|
|
267
|
-
authState.creds.me.id
|
|
268
|
-
],
|
|
283
|
+
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
284
|
+
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
269
285
|
participant: key.remoteJid,
|
|
270
|
-
messageTimestamp:
|
|
286
|
+
messageTimestamp: unixTimestampSeconds()
|
|
271
287
|
}, 'notify')
|
|
272
288
|
|
|
273
289
|
return results.attrs.from
|
|
@@ -297,57 +313,57 @@ const makeGroupsSocket = (config) => {
|
|
|
297
313
|
}
|
|
298
314
|
|
|
299
315
|
const extractGroupMetadata = (result) => {
|
|
300
|
-
const group =
|
|
301
|
-
const descChild =
|
|
302
|
-
const mode = group.attrs.addressing_mode ===
|
|
316
|
+
const group = getBinaryNodeChild(result, 'group')
|
|
317
|
+
const descChild = getBinaryNodeChild(group, 'description')
|
|
318
|
+
const mode = group.attrs.addressing_mode === WAMessageAddressingMode.LID ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN
|
|
303
319
|
|
|
304
320
|
let desc
|
|
305
321
|
let descId
|
|
306
322
|
let descOwner
|
|
307
|
-
let
|
|
323
|
+
let descOwnerAlt
|
|
308
324
|
|
|
309
325
|
if (descChild) {
|
|
310
|
-
desc =
|
|
326
|
+
desc = getBinaryNodeChildString(descChild, 'body')
|
|
311
327
|
descId = descChild.attrs.id
|
|
312
|
-
descOwner = mode ===
|
|
313
|
-
|
|
328
|
+
descOwner = mode === WAMessageAddressingMode.LID ? jidNormalizedUser(descChild.attrs.participant_pn) : jidNormalizedUser(descChild.attrs.participant)
|
|
329
|
+
descOwnerAlt = mode === WAMessageAddressingMode.LID ? jidNormalizedUser(descChild.attrs.participant) : undefined
|
|
314
330
|
}
|
|
315
331
|
|
|
316
|
-
const groupId = group.attrs.id.includes('@') ? group.attrs.id :
|
|
317
|
-
const eph =
|
|
318
|
-
const memberAddMode =
|
|
332
|
+
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us')
|
|
333
|
+
const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration
|
|
334
|
+
const memberAddMode = getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add'
|
|
319
335
|
|
|
320
336
|
const metadata = {
|
|
321
337
|
id: groupId,
|
|
322
|
-
addressingMode: mode,
|
|
323
338
|
subject: group.attrs.subject,
|
|
324
|
-
subjectOwner:
|
|
325
|
-
|
|
326
|
-
subjectTime:
|
|
327
|
-
size: group.attrs?.size ?
|
|
328
|
-
creation:
|
|
329
|
-
owner: group.attrs.creator ?
|
|
330
|
-
|
|
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,
|
|
331
346
|
ownerCountry: group.attrs.creator_country_code,
|
|
332
347
|
desc,
|
|
333
348
|
descId,
|
|
334
349
|
descOwner,
|
|
335
|
-
|
|
336
|
-
linkedParent:
|
|
337
|
-
restrict: !!
|
|
338
|
-
announce: !!
|
|
339
|
-
isCommunity: !!
|
|
340
|
-
isCommunityAnnounce: !!
|
|
341
|
-
joinApprovalMode: !!
|
|
350
|
+
descOwnerAlt,
|
|
351
|
+
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
|
352
|
+
restrict: !!getBinaryNodeChild(group, 'locked'),
|
|
353
|
+
announce: !!getBinaryNodeChild(group, 'announcement'),
|
|
354
|
+
isCommunity: !!getBinaryNodeChild(group, 'parent'),
|
|
355
|
+
isCommunityAnnounce: !!getBinaryNodeChild(group, 'default_sub_group'),
|
|
356
|
+
joinApprovalMode: !!getBinaryNodeChild(group, 'membership_approval_mode'),
|
|
342
357
|
memberAddMode,
|
|
343
|
-
participants:
|
|
358
|
+
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
344
359
|
return {
|
|
345
|
-
id: mode ===
|
|
346
|
-
lid: mode ===
|
|
347
|
-
admin: (attrs.type || null)
|
|
360
|
+
id: mode === WAMessageAddressingMode.LID ? attrs.phone_number : attrs.jid,
|
|
361
|
+
lid: mode === WAMessageAddressingMode.LID ? attrs.jid : attrs.lid,
|
|
362
|
+
admin: (attrs.type || null)
|
|
348
363
|
}
|
|
349
364
|
}),
|
|
350
|
-
ephemeralDuration: eph ?
|
|
365
|
+
ephemeralDuration: eph ? Number(eph) : undefined,
|
|
366
|
+
addressingMode: mode
|
|
351
367
|
}
|
|
352
368
|
|
|
353
369
|
return metadata
|
package/lib/Socket/index.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const { DEFAULT_CONNECTION_CONFIG } = require("../Defaults/connection")
|
|
6
|
+
const { makeCommunitiesSocket } = require("./community")
|
|
7
7
|
|
|
8
8
|
// export the last socket layer
|
|
9
9
|
const makeWASocket = (config) => {
|
|
10
10
|
const newConfig = {
|
|
11
|
-
...
|
|
11
|
+
...DEFAULT_CONNECTION_CONFIG,
|
|
12
12
|
...config
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -18,7 +18,7 @@ const makeWASocket = (config) => {
|
|
|
18
18
|
newConfig.shouldSyncHistoryMessage = () => !!newConfig.syncFullHistory
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
return
|
|
21
|
+
return makeCommunitiesSocket(newConfig)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
exports.default = makeWASocket
|