@langitdeveloper/baileys 2.0.7 → 2.0.9

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.
Files changed (126) hide show
  1. package/WAProto/index.js +131281 -59270
  2. package/lib/Defaults/baileys-version.json +3 -1
  3. package/lib/Defaults/index.js +6 -6
  4. package/lib/Function/Download/tiktok.js +19 -0
  5. package/lib/Function/Tools/bypass.js +19 -0
  6. package/lib/Function/index.js +13 -0
  7. package/lib/Signal/libsignal.js +0 -15
  8. package/lib/Socket/chats.js +48 -16
  9. package/lib/Socket/dugong.js +165 -12
  10. package/lib/Socket/messages-send.js +576 -1213
  11. package/lib/Socket/newsletter.js +212 -99
  12. package/lib/Socket/socket.js +1 -1
  13. package/lib/Types/index.js +0 -2
  14. package/lib/Utils/generics.js +79 -4
  15. package/lib/Utils/index.js +0 -4
  16. package/lib/Utils/messages.js +4 -33
  17. package/lib/WAUSync/Protocols/index.js +0 -2
  18. package/lib/index.js +10 -12
  19. package/package.json +7 -6
  20. package/lib/Defaults/index.d.ts +0 -53
  21. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  22. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  23. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  24. package/lib/Signal/Group/index.d.ts +0 -11
  25. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  26. package/lib/Signal/Group/queue-job.d.ts +0 -1
  27. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  28. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  29. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  30. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  31. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  32. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  33. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  34. package/lib/Signal/libsignal.d.ts +0 -3
  35. package/lib/Signal/lid-mapping.js +0 -164
  36. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  37. package/lib/Socket/Client/index.d.ts +0 -3
  38. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  39. package/lib/Socket/Client/types.js +0 -12
  40. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  41. package/lib/Socket/Client/websocket.js +0 -67
  42. package/lib/Socket/business.d.ts +0 -171
  43. package/lib/Socket/chats.d.ts +0 -267
  44. package/lib/Socket/community.js +0 -454
  45. package/lib/Socket/dugong.d.ts +0 -254
  46. package/lib/Socket/groups.d.ts +0 -115
  47. package/lib/Socket/index.d.ts +0 -173
  48. package/lib/Socket/messages-recv.d.ts +0 -161
  49. package/lib/Socket/messages-send.d.ts +0 -149
  50. package/lib/Socket/mex.js +0 -54
  51. package/lib/Socket/newsletter.d.ts +0 -134
  52. package/lib/Socket/registration.d.ts +0 -267
  53. package/lib/Socket/socket.d.ts +0 -43
  54. package/lib/Socket/usync.d.ts +0 -36
  55. package/lib/Store/index.d.ts +0 -3
  56. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  57. package/lib/Store/make-in-memory-store.d.ts +0 -118
  58. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  59. package/lib/Store/object-repository.d.ts +0 -10
  60. package/lib/Types/Auth.d.ts +0 -110
  61. package/lib/Types/Bussines.js +0 -2
  62. package/lib/Types/Call.d.ts +0 -13
  63. package/lib/Types/Chat.d.ts +0 -102
  64. package/lib/Types/Contact.d.ts +0 -19
  65. package/lib/Types/Events.d.ts +0 -157
  66. package/lib/Types/GroupMetadata.d.ts +0 -55
  67. package/lib/Types/Label.d.ts +0 -35
  68. package/lib/Types/LabelAssociation.d.ts +0 -29
  69. package/lib/Types/Message.d.ts +0 -273
  70. package/lib/Types/MexUpdates.js +0 -15
  71. package/lib/Types/Newsletter.d.ts +0 -103
  72. package/lib/Types/Product.d.ts +0 -78
  73. package/lib/Types/Signal.d.ts +0 -57
  74. package/lib/Types/Socket.d.ts +0 -111
  75. package/lib/Types/State.d.ts +0 -27
  76. package/lib/Types/USync.d.ts +0 -25
  77. package/lib/Types/index.d.ts +0 -57
  78. package/lib/Utils/auth-utils.d.ts +0 -18
  79. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  80. package/lib/Utils/browser-utils.js +0 -29
  81. package/lib/Utils/business.d.ts +0 -22
  82. package/lib/Utils/chat-utils.d.ts +0 -71
  83. package/lib/Utils/crypto.d.ts +0 -41
  84. package/lib/Utils/decode-wa-message.d.ts +0 -19
  85. package/lib/Utils/event-buffer.d.ts +0 -35
  86. package/lib/Utils/generics.d.ts +0 -92
  87. package/lib/Utils/history.d.ts +0 -15
  88. package/lib/Utils/index.d.ts +0 -17
  89. package/lib/Utils/link-preview.d.ts +0 -21
  90. package/lib/Utils/logger.d.ts +0 -4
  91. package/lib/Utils/lt-hash.d.ts +0 -12
  92. package/lib/Utils/make-mutex.d.ts +0 -7
  93. package/lib/Utils/message-retry-manager.js +0 -134
  94. package/lib/Utils/messages-media.d.ts +0 -116
  95. package/lib/Utils/messages.d.ts +0 -77
  96. package/lib/Utils/noise-handler.d.ts +0 -21
  97. package/lib/Utils/pre-key-manager.js +0 -86
  98. package/lib/Utils/process-message.d.ts +0 -41
  99. package/lib/Utils/signal.d.ts +0 -32
  100. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  101. package/lib/Utils/validate-connection.d.ts +0 -11
  102. package/lib/Utils/vialeys-event-stream.js +0 -41
  103. package/lib/WABinary/constants.d.ts +0 -30
  104. package/lib/WABinary/decode.d.ts +0 -7
  105. package/lib/WABinary/encode.d.ts +0 -3
  106. package/lib/WABinary/generic-utils.d.ts +0 -17
  107. package/lib/WABinary/index.d.ts +0 -5
  108. package/lib/WABinary/jid-utils.d.ts +0 -31
  109. package/lib/WABinary/types.d.ts +0 -18
  110. package/lib/WAM/BinaryInfo.d.ts +0 -17
  111. package/lib/WAM/constants.d.ts +0 -38
  112. package/lib/WAM/encode.d.ts +0 -3
  113. package/lib/WAM/index.d.ts +0 -3
  114. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -62
  115. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  116. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  117. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  118. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -24
  119. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  120. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  121. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  122. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  123. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  124. package/lib/WAUSync/USyncUser.d.ts +0 -12
  125. package/lib/WAUSync/index.d.ts +0 -3
  126. package/lib/index.d.ts +0 -12
@@ -1,454 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const { proto: proto } = require("../../WAProto");
4
- const { default: logger } = require("../Utils/logger");
5
- const {
6
- WAMessageStubType: WAMessageStubType,
7
- WAMessageAddressingMode: WAMessageAddressingMode,
8
- } = require("../Types");
9
- const {
10
- generateMessageID: generateMessageID,
11
- unixTimestampSeconds: unixTimestampSeconds,
12
- } = require("../Utils");
13
- const {
14
- getBinaryNodeChild: getBinaryNodeChild,
15
- getBinaryNodeChildren: getBinaryNodeChildren,
16
- getBinaryNodeChildString: getBinaryNodeChildString,
17
- jidEncode: jidEncode,
18
- jidNormalizedUser: jidNormalizedUser,
19
- } = require("../WABinary");
20
- const { makeBusinessSocket: makeBusinessSocket } = require("./business");
21
- const makeCommunitiesSocket = (config) => {
22
- const conn = makeBusinessSocket(config);
23
- const {
24
- authState: authState,
25
- ev: ev,
26
- query: query,
27
- groupMetadata: groupMetadata,
28
- upsertMessage: upsertMessage,
29
- cleanDirtyBits: cleanDirtyBits,
30
- } = conn;
31
- const communityQuery = async (jid, type, content) =>
32
- query({
33
- tag: "iq",
34
- attrs: { type: type, xmlns: "w:g2", to: jid },
35
- content: content,
36
- });
37
- const communityMetadata = async (jid) => {
38
- const result = await communityQuery(jid, "get", [
39
- { tag: "query", attrs: { request: "interactive" } },
40
- ]);
41
- return extractCommunityMetadata(result);
42
- };
43
- const communityFetchAllParticipating = async () => {
44
- const result = await query({
45
- tag: "iq",
46
- attrs: { to: "@g.us", xmlns: "w:g2", type: "get" },
47
- content: [
48
- {
49
- tag: "participating",
50
- attrs: {},
51
- content: [
52
- { tag: "participants", attrs: {} },
53
- { tag: "description", attrs: {} },
54
- ],
55
- },
56
- ],
57
- });
58
- const data = {};
59
- const communitiesChild = getBinaryNodeChild(result, "communities");
60
- if (communitiesChild) {
61
- const communities = getBinaryNodeChildren(communitiesChild, "community");
62
- for (const communityNode of communities) {
63
- const meta = extractCommunityMetadata({
64
- tag: "result",
65
- attrs: {},
66
- content: [communityNode],
67
- });
68
- data[meta.id] = meta;
69
- }
70
- }
71
- conn.ev.emit("groups.update", Object.values(data));
72
- return data;
73
- };
74
- async function parseGroupResult(node) {
75
- logger.info({ node: node }, "parseGroupResult");
76
- const groupNode = getBinaryNodeChild(node, "group");
77
- if (groupNode) {
78
- try {
79
- logger.info({ groupNode: groupNode }, "groupNode");
80
- const metadata = await groupMetadata(`${groupNode.attrs.id}@g.us`);
81
- return metadata ? metadata : null;
82
- } catch (error) {
83
- logger.warn({ error: error }, "Error parsing group metadata");
84
- return null;
85
- }
86
- }
87
- return null;
88
- }
89
- conn.ws.on("CB:ib,,dirty", async (node) => {
90
- const { attrs: attrs } = getBinaryNodeChild(node, "dirty");
91
- if (attrs.type !== "communities") {
92
- return;
93
- }
94
- await communityFetchAllParticipating();
95
- await cleanDirtyBits("groups");
96
- });
97
- return {
98
- ...conn,
99
- communityQuery: communityQuery,
100
- communityMetadata: communityMetadata,
101
- communityCreate: async (subject, body) => {
102
- const descriptionId = generateMessageID().substring(0, 12);
103
- const result = await communityQuery("@g.us", "set", [
104
- {
105
- tag: "create",
106
- attrs: { subject: subject },
107
- content: [
108
- {
109
- tag: "description",
110
- attrs: { id: descriptionId },
111
- content: [
112
- {
113
- tag: "body",
114
- attrs: {},
115
- content: Buffer.from(body || "", "utf-8"),
116
- },
117
- ],
118
- },
119
- {
120
- tag: "parent",
121
- attrs: { default_membership_approval_mode: "request_required" },
122
- },
123
- { tag: "allow_non_admin_sub_group_creation", attrs: {} },
124
- { tag: "create_general_chat", attrs: {} },
125
- ],
126
- },
127
- ]);
128
- return await parseGroupResult(result);
129
- },
130
- communityCreateGroup: async (subject, participants, parentCommunityJid) => {
131
- const key = generateMessageID();
132
- const result = await communityQuery("@g.us", "set", [
133
- {
134
- tag: "create",
135
- attrs: { subject: subject, key: key },
136
- content: [
137
- ...participants.map((jid) => ({
138
- tag: "participant",
139
- attrs: { jid: jid },
140
- })),
141
- { tag: "linked_parent", attrs: { jid: parentCommunityJid } },
142
- ],
143
- },
144
- ]);
145
- return await parseGroupResult(result);
146
- },
147
- communityLeave: async (id) => {
148
- await communityQuery("@g.us", "set", [
149
- {
150
- tag: "leave",
151
- attrs: {},
152
- content: [{ tag: "community", attrs: { id: id } }],
153
- },
154
- ]);
155
- },
156
- communityUpdateSubject: async (jid, subject) => {
157
- await communityQuery(jid, "set", [
158
- { tag: "subject", attrs: {}, content: Buffer.from(subject, "utf-8") },
159
- ]);
160
- },
161
- communityLinkGroup: async (groupJid, parentCommunityJid) => {
162
- await communityQuery(parentCommunityJid, "set", [
163
- {
164
- tag: "links",
165
- attrs: {},
166
- content: [
167
- {
168
- tag: "link",
169
- attrs: { link_type: "sub_group" },
170
- content: [{ tag: "group", attrs: { jid: groupJid } }],
171
- },
172
- ],
173
- },
174
- ]);
175
- },
176
- communityUnlinkGroup: async (groupJid, parentCommunityJid) => {
177
- await communityQuery(parentCommunityJid, "set", [
178
- {
179
- tag: "unlink",
180
- attrs: { unlink_type: "sub_group" },
181
- content: [{ tag: "group", attrs: { jid: groupJid } }],
182
- },
183
- ]);
184
- },
185
- communityFetchLinkedGroups: async (jid) => {
186
- let communityJid = jid;
187
- let isCommunity = false;
188
- const metadata = await groupMetadata(jid);
189
- if (metadata.linkedParent) {
190
- communityJid = metadata.linkedParent;
191
- } else {
192
- isCommunity = true;
193
- }
194
- const result = await communityQuery(communityJid, "get", [
195
- { tag: "sub_groups", attrs: {} },
196
- ]);
197
- const linkedGroupsData = [];
198
- const subGroupsNode = getBinaryNodeChild(result, "sub_groups");
199
- if (subGroupsNode) {
200
- const groupNodes = getBinaryNodeChildren(subGroupsNode, "group");
201
- for (const groupNode of groupNodes) {
202
- linkedGroupsData.push({
203
- id: groupNode.attrs.id ? jidEncode(groupNode.attrs.id, "g.us") : undefined,
204
- subject: groupNode.attrs.subject || "",
205
- creation: groupNode.attrs.creation
206
- ? Number(groupNode.attrs.creation)
207
- : undefined,
208
- owner: groupNode.attrs.creator
209
- ? jidNormalizedUser(groupNode.attrs.creator)
210
- : undefined,
211
- size: groupNode.attrs.size ? Number(groupNode.attrs.size) : undefined,
212
- });
213
- }
214
- }
215
- return {
216
- communityJid: communityJid,
217
- isCommunity: isCommunity,
218
- linkedGroups: linkedGroupsData,
219
- };
220
- },
221
- communityRequestParticipantsList: async (jid) => {
222
- const result = await communityQuery(jid, "get", [
223
- { tag: "membership_approval_requests", attrs: {} },
224
- ]);
225
- const node = getBinaryNodeChild(result, "membership_approval_requests");
226
- const participants = getBinaryNodeChildren(node, "membership_approval_request");
227
- return participants.map((v) => v.attrs);
228
- },
229
- communityRequestParticipantsUpdate: async (jid, participants, action) => {
230
- const result = await communityQuery(jid, "set", [
231
- {
232
- tag: "membership_requests_action",
233
- attrs: {},
234
- content: [
235
- {
236
- tag: action,
237
- attrs: {},
238
- content: participants.map((jid) => ({
239
- tag: "participant",
240
- attrs: { jid: jid },
241
- })),
242
- },
243
- ],
244
- },
245
- ]);
246
- const node = getBinaryNodeChild(result, "membership_requests_action");
247
- const nodeAction = getBinaryNodeChild(node, action);
248
- const participantsAffected = getBinaryNodeChildren(nodeAction, "participant");
249
- return participantsAffected.map((p) => ({
250
- status: p.attrs.error || "200",
251
- jid: p.attrs.jid,
252
- }));
253
- },
254
- communityParticipantsUpdate: async (jid, participants, action) => {
255
- const result = await communityQuery(jid, "set", [
256
- {
257
- tag: action,
258
- attrs: action === "remove" ? { linked_groups: "true" } : {},
259
- content: participants.map((jid) => ({
260
- tag: "participant",
261
- attrs: { jid: jid },
262
- })),
263
- },
264
- ]);
265
- const node = getBinaryNodeChild(result, action);
266
- const participantsAffected = getBinaryNodeChildren(node, "participant");
267
- return participantsAffected.map((p) => ({
268
- status: p.attrs.error || "200",
269
- jid: p.attrs.jid,
270
- content: p,
271
- }));
272
- },
273
- communityUpdateDescription: async (jid, description) => {
274
- const metadata = await communityMetadata(jid);
275
- const prev = metadata.descId ?? null;
276
- await communityQuery(jid, "set", [
277
- {
278
- tag: "description",
279
- attrs: {
280
- ...(description ? { id: generateMessageID() } : { delete: "true" }),
281
- ...(prev ? { prev: prev } : {}),
282
- },
283
- content: description
284
- ? [
285
- {
286
- tag: "body",
287
- attrs: {},
288
- content: Buffer.from(description, "utf-8"),
289
- },
290
- ]
291
- : undefined,
292
- },
293
- ]);
294
- },
295
- communityInviteCode: async (jid) => {
296
- const result = await communityQuery(jid, "get", [{ tag: "invite", attrs: {} }]);
297
- const inviteNode = getBinaryNodeChild(result, "invite");
298
- return inviteNode?.attrs.code;
299
- },
300
- communityRevokeInvite: async (jid) => {
301
- const result = await communityQuery(jid, "set", [{ tag: "invite", attrs: {} }]);
302
- const inviteNode = getBinaryNodeChild(result, "invite");
303
- return inviteNode?.attrs.code;
304
- },
305
- communityAcceptInvite: async (code) => {
306
- const results = await communityQuery("@g.us", "set", [
307
- { tag: "invite", attrs: { code: code } },
308
- ]);
309
- const result = getBinaryNodeChild(results, "community");
310
- return result?.attrs.jid;
311
- },
312
- communityRevokeInviteV4: async (communityJid, invitedJid) => {
313
- const result = await communityQuery(communityJid, "set", [
314
- {
315
- tag: "revoke",
316
- attrs: {},
317
- content: [{ tag: "participant", attrs: { jid: invitedJid } }],
318
- },
319
- ]);
320
- return !!result;
321
- },
322
- communityAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
323
- key = typeof key === "string" ? { remoteJid: key } : key;
324
- const results = await communityQuery(inviteMessage.groupJid, "set", [
325
- {
326
- tag: "accept",
327
- attrs: {
328
- code: inviteMessage.inviteCode,
329
- expiration: inviteMessage.inviteExpiration.toString(),
330
- admin: key.remoteJid,
331
- },
332
- },
333
- ]);
334
- if (key.id) {
335
- inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage);
336
- inviteMessage.inviteExpiration = 0;
337
- inviteMessage.inviteCode = "";
338
- ev.emit("messages.update", [
339
- {
340
- key: key,
341
- update: { message: { groupInviteMessage: inviteMessage } },
342
- },
343
- ]);
344
- }
345
- await upsertMessage(
346
- {
347
- key: {
348
- remoteJid: inviteMessage.groupJid,
349
- id: generateMessageID(conn.user?.id),
350
- fromMe: false,
351
- participant: key.remoteJid,
352
- },
353
- messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
354
- messageStubParameters: [JSON.stringify(authState.creds.me)],
355
- participant: key.remoteJid,
356
- messageTimestamp: unixTimestampSeconds(),
357
- },
358
- "notify"
359
- );
360
- return results.attrs.from;
361
- }),
362
- communityGetInviteInfo: async (code) => {
363
- const results = await communityQuery("@g.us", "get", [
364
- { tag: "invite", attrs: { code: code } },
365
- ]);
366
- return extractCommunityMetadata(results);
367
- },
368
- communityToggleEphemeral: async (jid, ephemeralExpiration) => {
369
- const content = ephemeralExpiration
370
- ? {
371
- tag: "ephemeral",
372
- attrs: { expiration: ephemeralExpiration.toString() },
373
- }
374
- : { tag: "not_ephemeral", attrs: {} };
375
- await communityQuery(jid, "set", [content]);
376
- },
377
- communitySettingUpdate: async (jid, setting) => {
378
- await communityQuery(jid, "set", [{ tag: setting, attrs: {} }]);
379
- },
380
- communityMemberAddMode: async (jid, mode) => {
381
- await communityQuery(jid, "set", [
382
- { tag: "member_add_mode", attrs: {}, content: mode },
383
- ]);
384
- },
385
- communityJoinApprovalMode: async (jid, mode) => {
386
- await communityQuery(jid, "set", [
387
- {
388
- tag: "membership_approval_mode",
389
- attrs: {},
390
- content: [{ tag: "community_join", attrs: { state: mode } }],
391
- },
392
- ]);
393
- },
394
- communityFetchAllParticipating: communityFetchAllParticipating,
395
- };
396
- };
397
- const extractCommunityMetadata = (result) => {
398
- const community = getBinaryNodeChild(result, "group");
399
- const descChild = getBinaryNodeChild(community, "description");
400
- let desc;
401
- let descId;
402
- if (descChild) {
403
- desc = getBinaryNodeChildString(descChild, "body");
404
- descId = descChild.attrs.id;
405
- }
406
- const mode = community.attrs.addressing_mode;
407
- const communityId = community.attrs.id.includes("@")
408
- ? community.attrs.id
409
- : jidEncode(community.attrs.id, "g.us");
410
- const eph = getBinaryNodeChild(community, "ephemeral")?.attrs.expiration;
411
- const memberAddMode =
412
- getBinaryNodeChildString(community, "member_add_mode") === "all_member_add";
413
- const metadata = {
414
- id: communityId,
415
- subject: community.attrs.subject,
416
- subjectOwner: community.attrs.s_o,
417
- subjectOwnerAlt: community.attrs?.s_o_pn ? community.attrs.s_o_pn : community.attrs.s_o,
418
- subjectTime: Number(community.attrs.s_t || 0),
419
- size: Number(
420
- community.attrs?.size
421
- ? community.attrs.size
422
- : getBinaryNodeChildren(community, "participant").length
423
- ),
424
- creation: Number(community.attrs.creation || 0),
425
- owner: community.attrs.creator ? jidNormalizedUser(community.attrs.creator) : undefined,
426
- ownerAlt: community.attrs.creator
427
- ? jidNormalizedUser(
428
- community.attrs?.creator_pn ? community.attrs.creator_pn : community.attrs.creator
429
- )
430
- : undefined,
431
- ownerCountry: community.attrs.creator_country_code,
432
- desc: desc,
433
- descId: descId,
434
- linkedParent: getBinaryNodeChild(community, "linked_parent")?.attrs.jid || undefined,
435
- restrict: !!getBinaryNodeChild(community, "locked"),
436
- announce: !!getBinaryNodeChild(community, "announcement"),
437
- isCommunity: !!getBinaryNodeChild(community, "parent"),
438
- isCommunityAnnounce: !!getBinaryNodeChild(community, "default_sub_group"),
439
- joinApprovalMode: !!getBinaryNodeChild(community, "membership_approval_mode"),
440
- memberAddMode: memberAddMode,
441
- participants: getBinaryNodeChildren(community, "participant").map(({ attrs: attrs }) => ({
442
- id: mode === WAMessageAddressingMode.LID ? community.phone_number : attrs.jid,
443
- lid: mode === WAMessageAddressingMode.LID ? community.jid : attrs.lid,
444
- admin: attrs.type || null,
445
- })),
446
- ephemeralDuration: eph ? Number(ph) : undefined,
447
- addressingMode: mode,
448
- };
449
- return metadata;
450
- };
451
- module.exports = {
452
- makeCommunitiesSocket: makeCommunitiesSocket,
453
- extractCommunityMetadata: extractCommunityMetadata,
454
- };