@badzz88/baileys 8.5.6 → 8.5.7
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 +2 -2
- package/WAProto/WAProto.proto +75 -1256
- package/WAProto/fix-imports.js +79 -69
- package/WAProto/index.d.ts +71491 -15254
- package/WAProto/index.js +126432 -19810
- package/engine-requirements.js +4 -3
- package/lib/Defaults/index.js +187 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +92 -0
- package/lib/Signal/Group/group_cipher.js +89 -0
- package/lib/Signal/Group/index.js +136 -0
- package/lib/Signal/Group/keyhelper.js +73 -0
- package/lib/Signal/Group/sender-chain-key.js +32 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +50 -0
- package/lib/Signal/Group/sender-key-record.js +44 -0
- package/lib/Signal/Group/sender-key-state.js +97 -0
- package/lib/Signal/Group/sender-message-key.js +30 -0
- package/lib/Signal/libsignal.js +459 -0
- package/lib/Signal/lid-mapping.js +260 -0
- package/lib/Socket/Client/index.js +30 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +62 -0
- package/lib/Socket/aigroups.js +240 -0
- package/lib/Socket/business.js +422 -0
- package/lib/Socket/chats.js +1816 -0
- package/lib/Socket/communities.js +549 -0
- package/lib/Socket/graphql.js +656 -0
- package/lib/Socket/groups.js +764 -0
- package/lib/Socket/index.js +39 -0
- package/lib/Socket/interactive-handler.js +522 -0
- package/lib/Socket/interop.js +549 -0
- package/{src → lib}/Socket/luxu.js +120 -82
- package/lib/Socket/managed-account.js +183 -0
- package/lib/Socket/messages-recv.js +2442 -0
- package/lib/Socket/messages-send.js +1853 -0
- package/lib/Socket/mex.js +60 -0
- package/lib/Socket/newsletter.js +818 -0
- package/lib/Socket/privacy.js +449 -0
- package/lib/Socket/registration.js +427 -0
- package/lib/Socket/socket.js +1092 -0
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +243 -0
- package/lib/Store/index.js +36 -0
- package/{src → lib}/Store/keyed-db.js +11 -21
- package/lib/Store/make-cache-manager-store.js +90 -0
- package/lib/Store/make-in-memory-store.js +604 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +29 -0
- package/lib/Types/Auth.js +38 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +95 -0
- package/lib/Types/Mex.js +112 -0
- package/lib/Types/Newsletter.js +121 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +70 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +55 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/browser-utils.js +114 -0
- package/lib/Utils/business.js +247 -0
- package/lib/Utils/chat-utils.js +1208 -0
- package/lib/Utils/command-loader.d.ts +31 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +42 -0
- package/lib/Utils/consumer-application.js +107 -0
- package/lib/Utils/crypto.js +155 -0
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +560 -0
- package/lib/Utils/event-buffer.js +607 -0
- package/lib/Utils/generics.js +563 -0
- package/lib/Utils/group-history.js +60 -0
- package/lib/Utils/history.js +244 -0
- package/lib/Utils/identity-change-handler.js +52 -0
- package/lib/Utils/index.js +57 -0
- package/lib/Utils/jid-display-normalization.js +218 -0
- package/lib/Utils/link-preview.js +143 -0
- package/lib/Utils/logger.js +9 -0
- package/lib/Utils/lt-hash.js +39 -0
- package/lib/Utils/make-mutex.js +36 -0
- package/lib/Utils/message-composer.js +479 -0
- package/lib/Utils/message-retry-manager.js +270 -0
- package/lib/Utils/messages-media.js +896 -0
- package/lib/Utils/messages.js +2904 -0
- package/lib/Utils/meta-ai-msmsg.js +262 -0
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +196 -0
- package/lib/Utils/offline-node-processor.js +42 -0
- package/lib/Utils/pre-key-manager.js +107 -0
- package/lib/Utils/process-message.js +1048 -0
- package/lib/Utils/reporting-utils.js +262 -0
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +224 -0
- package/lib/Utils/stanza-ack.js +40 -0
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +54 -0
- package/lib/Utils/tc-token-utils.js +161 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/validate-connection.js +219 -0
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/Utils/voip-rekey.js +22 -0
- package/lib/WABinary/constants.js +1304 -0
- package/lib/WABinary/decode.js +343 -0
- package/{src → lib}/WABinary/encode.js +12 -9
- package/lib/WABinary/generic-utils.js +240 -0
- package/lib/WABinary/index.js +33 -0
- package/lib/WABinary/jid-utils.js +361 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +39486 -0
- package/lib/WAM/encode.js +142 -0
- package/lib/WAM/index.js +31 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +55 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +43 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +59 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +31 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +27 -0
- package/lib/WAUSync/Protocols/index.js +39 -0
- package/lib/WAUSync/USyncQuery.js +133 -0
- package/lib/WAUSync/USyncUser.js +50 -0
- package/lib/WAUSync/index.js +31 -0
- package/lib/antiban.js +4637 -0
- package/{src → lib}/index.js +49 -51
- package/package.json +4 -4
- package/src/Defaults/index.js +0 -186
- package/src/Signal/Group/ciphertext-message.js +0 -15
- package/src/Signal/Group/group-session-builder.js +0 -86
- package/src/Signal/Group/group_cipher.js +0 -82
- package/src/Signal/Group/index.js +0 -140
- package/src/Signal/Group/keyhelper.js +0 -77
- package/src/Signal/Group/sender-chain-key.js +0 -29
- package/src/Signal/Group/sender-key-distribution-message.js +0 -66
- package/src/Signal/Group/sender-key-message.js +0 -69
- package/src/Signal/Group/sender-key-name.js +0 -51
- package/src/Signal/Group/sender-key-record.js +0 -44
- package/src/Signal/Group/sender-key-state.js +0 -87
- package/src/Signal/Group/sender-message-key.js +0 -29
- package/src/Signal/libsignal.js +0 -455
- package/src/Signal/lid-mapping.js +0 -273
- package/src/Socket/Client/index.js +0 -31
- package/src/Socket/Client/types.js +0 -13
- package/src/Socket/Client/websocket.js +0 -61
- package/src/Socket/aigroups.js +0 -221
- package/src/Socket/business.js +0 -411
- package/src/Socket/chats.js +0 -1449
- package/src/Socket/communities.js +0 -463
- package/src/Socket/graphql.js +0 -523
- package/src/Socket/groups.js +0 -516
- package/src/Socket/index.js +0 -31
- package/src/Socket/interactive-handler.js +0 -527
- package/src/Socket/interop.js +0 -339
- package/src/Socket/managed-account.js +0 -98
- package/src/Socket/messages-recv.js +0 -2685
- package/src/Socket/messages-send.js +0 -2047
- package/src/Socket/mex.js +0 -57
- package/src/Socket/newsletter.js +0 -455
- package/src/Socket/privacy.js +0 -125
- package/src/Socket/registration.js +0 -236
- package/src/Socket/socket.js +0 -983
- package/src/Socket/text-router.js +0 -65
- package/src/Socket/username.js +0 -130
- package/src/Store/index.js +0 -33
- package/src/Store/make-cache-manager-store.js +0 -84
- package/src/Store/make-in-memory-store.js +0 -551
- package/src/Store/make-ordered-dictionary.js +0 -81
- package/src/Store/object-repository.js +0 -26
- package/src/Types/Auth.js +0 -31
- package/src/Types/Bussines.js +0 -2
- package/src/Types/Call.js +0 -2
- package/src/Types/Chat.js +0 -4
- package/src/Types/Contact.js +0 -2
- package/src/Types/Events.js +0 -2
- package/src/Types/GroupMetadata.js +0 -2
- package/src/Types/Label.js +0 -26
- package/src/Types/LabelAssociation.js +0 -8
- package/src/Types/Message.js +0 -93
- package/src/Types/Mex.js +0 -112
- package/src/Types/Newsletter.js +0 -109
- package/src/Types/Product.js +0 -2
- package/src/Types/Signal.js +0 -2
- package/src/Types/Socket.js +0 -2
- package/src/Types/State.js +0 -62
- package/src/Types/USync.js +0 -2
- package/src/Types/index.js +0 -56
- package/src/Utils/auth-utils.js +0 -254
- package/src/Utils/browser-utils.js +0 -112
- package/src/Utils/business.js +0 -240
- package/src/Utils/chat-utils.js +0 -1230
- package/src/Utils/command-loader.d.ts +0 -27
- package/src/Utils/command-loader.js +0 -89
- package/src/Utils/companion-reg-client-utils.js +0 -40
- package/src/Utils/consumer-application.js +0 -105
- package/src/Utils/crypto.js +0 -118
- package/src/Utils/curve25519-js.js +0 -242
- package/src/Utils/decode-wa-message.js +0 -529
- package/src/Utils/event-buffer.js +0 -580
- package/src/Utils/generics.js +0 -483
- package/src/Utils/group-history.js +0 -44
- package/src/Utils/history.js +0 -232
- package/src/Utils/identity-change-handler.js +0 -52
- package/src/Utils/index.js +0 -58
- package/src/Utils/jid-display-normalization.js +0 -195
- package/src/Utils/link-preview.js +0 -135
- package/src/Utils/logger.js +0 -8
- package/src/Utils/lt-hash.js +0 -25
- package/src/Utils/make-mutex.js +0 -36
- package/src/Utils/message-composer.js +0 -471
- package/src/Utils/message-retry-manager.js +0 -217
- package/src/Utils/messages-media.js +0 -843
- package/src/Utils/messages.js +0 -2817
- package/src/Utils/meta-ai-msmsg.js +0 -222
- package/src/Utils/native-bridge.js +0 -68
- package/src/Utils/noise-handler.js +0 -169
- package/src/Utils/offline-node-processor.js +0 -34
- package/src/Utils/pre-key-manager.js +0 -90
- package/src/Utils/process-message.js +0 -950
- package/src/Utils/reporting-utils.js +0 -261
- package/src/Utils/session-pool.d.ts +0 -14
- package/src/Utils/session-pool.js +0 -70
- package/src/Utils/signal.js +0 -217
- package/src/Utils/stanza-ack.js +0 -30
- package/src/Utils/sticker.d.ts +0 -13
- package/src/Utils/sticker.js +0 -123
- package/src/Utils/sync-action-utils.js +0 -45
- package/src/Utils/tc-token-utils.js +0 -158
- package/src/Utils/use-multi-file-auth-state.js +0 -111
- package/src/Utils/validate-connection.js +0 -209
- package/src/Utils/view-once-cache.d.ts +0 -12
- package/src/Utils/view-once-cache.js +0 -63
- package/src/Utils/voip-rekey.js +0 -22
- package/src/WABinary/constants.js +0 -1304
- package/src/WABinary/decode.js +0 -342
- package/src/WABinary/generic-utils.js +0 -238
- package/src/WABinary/index.js +0 -34
- package/src/WABinary/jid-utils.js +0 -351
- package/src/WABinary/types.js +0 -2
- package/src/WAM/BinaryInfo.js +0 -13
- package/src/WAM/constants.js +0 -39484
- package/src/WAM/encode.js +0 -149
- package/src/WAM/index.js +0 -32
- package/src/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -53
- package/src/WAUSync/Protocols/USyncBusinessProtocol.js +0 -44
- package/src/WAUSync/Protocols/USyncContactProtocol.js +0 -55
- package/src/WAUSync/Protocols/USyncDeviceProtocol.js +0 -55
- package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -31
- package/src/WAUSync/Protocols/USyncFeatureProtocol.js +0 -54
- package/src/WAUSync/Protocols/USyncLIDProtocol.js +0 -32
- package/src/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -473
- package/src/WAUSync/Protocols/USyncPictureProtocol.js +0 -34
- package/src/WAUSync/Protocols/USyncSidelistProtocol.js +0 -29
- package/src/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
- package/src/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -38
- package/src/WAUSync/Protocols/USyncUsernameProtocol.js +0 -28
- package/src/WAUSync/Protocols/index.js +0 -40
- package/src/WAUSync/USyncQuery.js +0 -126
- package/src/WAUSync/USyncUser.js +0 -50
- package/src/WAUSync/index.js +0 -32
- package/src/antiban.js +0 -4152
- /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
package/src/Socket/groups.js
DELETED
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.extractGroupMetadata = exports.makeGroupsSocket = void 0;
|
|
4
|
-
const index_js_1 = require('../../WAProto/index.js');
|
|
5
|
-
const Types_1 = require('../Types');
|
|
6
|
-
const Utils_1 = require('../Utils');
|
|
7
|
-
const WABinary_1 = require('../WABinary');
|
|
8
|
-
const chats_1 = require('./chats');
|
|
9
|
-
const mex_1 = require('./mex');
|
|
10
|
-
const GROUP_MEX_QUERY_IDS = {
|
|
11
|
-
QUERY_INFO: '25530136513328492',
|
|
12
|
-
QUERY_INFO_BY_CODE: '24576337542042464',
|
|
13
|
-
QUERY_BATCH: '26440064815661176',
|
|
14
|
-
QUERY_INVITE_LINK: '24558418350455204',
|
|
15
|
-
QUERY_PARTICIPATING: '26664341543184776',
|
|
16
|
-
QUERY_SUGGESTED: '26012055225051916',
|
|
17
|
-
QUERY_LINKED: '25629003043401452',
|
|
18
|
-
QUERY_SUBGROUPS: '25554052094203120',
|
|
19
|
-
ADD_PARTICIPANTS_V2: '32627550323510250',
|
|
20
|
-
ADD_PARTICIPANTS_V3: '26581073158212628',
|
|
21
|
-
SET_PROPERTY: '24688994337458820',
|
|
22
|
-
RESET_INVITE_LINK: '24812851838367452',
|
|
23
|
-
CREATE_INVITE_CODE: '25207706598901440',
|
|
24
|
-
CREATE_GROUP: '32341779532133480',
|
|
25
|
-
ALLOW_NON_ADMIN_GROUP_CREATION: '32024438593867696',
|
|
26
|
-
GET_INVITE_INFO: '24745668928467084',
|
|
27
|
-
GET_PRE_REG_ADD_REQUESTS: '25018599251091280',
|
|
28
|
-
GET_SUGGESTED_CONTACTS: '27208468032086900',
|
|
29
|
-
STORE_INVITES_SMS: '25508574885415376',
|
|
30
|
-
LOG_SERVER_SENT_INVITE: '26580640204871220',
|
|
31
|
-
QUERY_ONLINE_STATUS: '24599444653063564',
|
|
32
|
-
QUERY_ONLINE_STATUS_LAST_SEEN: '24653084284365540'
|
|
33
|
-
};
|
|
34
|
-
const makeGroupsSocket = config => {
|
|
35
|
-
const sock = (0, chats_1.makeChatsSocket)(config);
|
|
36
|
-
const { authState, ev, query, generateMessageTag, upsertMessage } = sock;
|
|
37
|
-
const groupQuery = async (jid, type, content) => query({
|
|
38
|
-
tag: 'iq',
|
|
39
|
-
attrs: {
|
|
40
|
-
type,
|
|
41
|
-
xmlns: 'w:g2',
|
|
42
|
-
to: jid
|
|
43
|
-
},
|
|
44
|
-
content
|
|
45
|
-
});
|
|
46
|
-
const mexQuery = (variables, queryId, dataPath) => (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag);
|
|
47
|
-
const groupMetadata = async (jid) => {
|
|
48
|
-
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
49
|
-
return (0, exports.extractGroupMetadata)(result);
|
|
50
|
-
};
|
|
51
|
-
const groupAcknowledge = async (jid) => {
|
|
52
|
-
await groupQuery(jid, 'set', [{ tag: 'ack', attrs: {} }]);
|
|
53
|
-
};
|
|
54
|
-
const groupGetLinkedParticipants = async (jid) => {
|
|
55
|
-
const result = await groupQuery(jid, 'get', [{ tag: 'linked_groups_participants', attrs: {} }]);
|
|
56
|
-
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'linked_groups_participants');
|
|
57
|
-
return (0, WABinary_1.getBinaryNodeChildren)(node, 'participant').map(p => ({
|
|
58
|
-
jid: p.attrs.jid,
|
|
59
|
-
phoneNumber: p.attrs.phone_number || p.attrs.pn || undefined
|
|
60
|
-
}));
|
|
61
|
-
};
|
|
62
|
-
const groupJoinLinked = async (parentJid, linkedGroupJid, type) => {
|
|
63
|
-
const result = await groupQuery(parentJid, 'set', [
|
|
64
|
-
{ tag: 'join_linked_group', attrs: { jid: linkedGroupJid, ...(type ? { type } : {}) } }
|
|
65
|
-
]);
|
|
66
|
-
return { approvalRequested: !!(0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_request') };
|
|
67
|
-
};
|
|
68
|
-
const getGroupProfilePictures = async (jids, type = 'preview') => {
|
|
69
|
-
const result = await groupQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
70
|
-
{
|
|
71
|
-
tag: 'pictures',
|
|
72
|
-
attrs: {},
|
|
73
|
-
content: jids.map(id => ({ tag: 'picture', attrs: { id, type } }))
|
|
74
|
-
}
|
|
75
|
-
]);
|
|
76
|
-
return (0, WABinary_1.getBinaryNodeChildren)(result, 'picture').map(pic => ({
|
|
77
|
-
jid: pic.attrs.id || pic.attrs.jid,
|
|
78
|
-
type: pic.attrs.type,
|
|
79
|
-
directPath: pic.attrs['direct_path'],
|
|
80
|
-
url: pic.attrs.url
|
|
81
|
-
}));
|
|
82
|
-
};
|
|
83
|
-
const groupCreateSubGroupSuggestion = async (parentJid, suggestion) => {
|
|
84
|
-
await groupQuery(parentJid, 'set', [{ tag: 'sub_group_suggestion', attrs: {}, content: suggestion }]);
|
|
85
|
-
};
|
|
86
|
-
const groupSubGroupSuggestionsAction = async (parentJid, action, suggestions) => {
|
|
87
|
-
await groupQuery(parentJid, 'set', [
|
|
88
|
-
{
|
|
89
|
-
tag: action,
|
|
90
|
-
attrs: {},
|
|
91
|
-
content: suggestions.map(s => ({
|
|
92
|
-
tag: 'sub_group_suggestion',
|
|
93
|
-
attrs: { creator: s.creator, ...(s.jid ? { jid: s.jid } : {}) }
|
|
94
|
-
}))
|
|
95
|
-
}
|
|
96
|
-
]);
|
|
97
|
-
};
|
|
98
|
-
const groupFetchAllParticipating = async () => {
|
|
99
|
-
const result = await query({
|
|
100
|
-
tag: 'iq',
|
|
101
|
-
attrs: {
|
|
102
|
-
to: '@g.us',
|
|
103
|
-
xmlns: 'w:g2',
|
|
104
|
-
type: 'get'
|
|
105
|
-
},
|
|
106
|
-
content: [
|
|
107
|
-
{
|
|
108
|
-
tag: 'participating',
|
|
109
|
-
attrs: {},
|
|
110
|
-
content: [
|
|
111
|
-
{ tag: 'participants', attrs: {} },
|
|
112
|
-
{ tag: 'description', attrs: {} }
|
|
113
|
-
]
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
});
|
|
117
|
-
const data = {};
|
|
118
|
-
const groupsChild = (0, WABinary_1.getBinaryNodeChild)(result, 'groups');
|
|
119
|
-
if (groupsChild) {
|
|
120
|
-
const groups = (0, WABinary_1.getBinaryNodeChildren)(groupsChild, 'group');
|
|
121
|
-
for (const groupNode of groups) {
|
|
122
|
-
const meta = (0, exports.extractGroupMetadata)({
|
|
123
|
-
tag: 'result',
|
|
124
|
-
attrs: {},
|
|
125
|
-
content: [groupNode]
|
|
126
|
-
});
|
|
127
|
-
data[meta.id] = meta;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
sock.ev.emit('groups.update', Object.values(data));
|
|
131
|
-
return data;
|
|
132
|
-
};
|
|
133
|
-
sock.ws.on('CB:ib,,dirty', async (node) => {
|
|
134
|
-
const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
|
|
135
|
-
if (attrs.type !== 'groups') {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
await groupFetchAllParticipating();
|
|
139
|
-
await sock.cleanDirtyBits('groups');
|
|
140
|
-
});
|
|
141
|
-
return {
|
|
142
|
-
...sock,
|
|
143
|
-
groupMetadata,
|
|
144
|
-
groupAcknowledge,
|
|
145
|
-
groupGetLinkedParticipants,
|
|
146
|
-
groupJoinLinked,
|
|
147
|
-
getGroupProfilePictures,
|
|
148
|
-
groupCreateSubGroupSuggestion,
|
|
149
|
-
groupSubGroupSuggestionsAction,
|
|
150
|
-
groupCreate: async (subject, participants) => {
|
|
151
|
-
const key = (0, Utils_1.generateMessageIDV2)();
|
|
152
|
-
const result = await groupQuery('@g.us', 'set', [
|
|
153
|
-
{
|
|
154
|
-
tag: 'create',
|
|
155
|
-
attrs: {
|
|
156
|
-
subject,
|
|
157
|
-
key
|
|
158
|
-
},
|
|
159
|
-
content: participants.map(jid => ({
|
|
160
|
-
tag: 'participant',
|
|
161
|
-
attrs: { jid }
|
|
162
|
-
}))
|
|
163
|
-
}
|
|
164
|
-
]);
|
|
165
|
-
return (0, exports.extractGroupMetadata)(result);
|
|
166
|
-
},
|
|
167
|
-
groupLeave: async (id) => {
|
|
168
|
-
await groupQuery('@g.us', 'set', [
|
|
169
|
-
{
|
|
170
|
-
tag: 'leave',
|
|
171
|
-
attrs: {},
|
|
172
|
-
content: [{ tag: 'group', attrs: { id } }]
|
|
173
|
-
}
|
|
174
|
-
]);
|
|
175
|
-
},
|
|
176
|
-
groupUpdateSubject: async (jid, subject) => {
|
|
177
|
-
await groupQuery(jid, 'set', [
|
|
178
|
-
{
|
|
179
|
-
tag: 'subject',
|
|
180
|
-
attrs: {},
|
|
181
|
-
content: Buffer.from(subject, 'utf-8')
|
|
182
|
-
}
|
|
183
|
-
]);
|
|
184
|
-
},
|
|
185
|
-
groupRequestParticipantsList: async (jid) => {
|
|
186
|
-
const result = await groupQuery(jid, 'get', [
|
|
187
|
-
{
|
|
188
|
-
tag: 'membership_approval_requests',
|
|
189
|
-
attrs: {}
|
|
190
|
-
}
|
|
191
|
-
]);
|
|
192
|
-
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_approval_requests');
|
|
193
|
-
const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'membership_approval_request');
|
|
194
|
-
return participants.map(v => v.attrs);
|
|
195
|
-
},
|
|
196
|
-
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
197
|
-
const result = await groupQuery(jid, 'set', [
|
|
198
|
-
{
|
|
199
|
-
tag: 'membership_requests_action',
|
|
200
|
-
attrs: {},
|
|
201
|
-
content: [
|
|
202
|
-
{
|
|
203
|
-
tag: action,
|
|
204
|
-
attrs: {},
|
|
205
|
-
content: participants.map(jid => ({
|
|
206
|
-
tag: 'participant',
|
|
207
|
-
attrs: { jid }
|
|
208
|
-
}))
|
|
209
|
-
}
|
|
210
|
-
]
|
|
211
|
-
}
|
|
212
|
-
]);
|
|
213
|
-
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
|
|
214
|
-
const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
|
|
215
|
-
const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
|
|
216
|
-
return participantsAffected.map(p => {
|
|
217
|
-
return { status: p.attrs.error || '200', jid: p.attrs.jid };
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
groupParticipantsUpdate: async (jid, participants, action) => {
|
|
221
|
-
const result = await groupQuery(jid, 'set', [
|
|
222
|
-
{
|
|
223
|
-
tag: action,
|
|
224
|
-
attrs: {},
|
|
225
|
-
content: participants.map(jid => ({
|
|
226
|
-
tag: 'participant',
|
|
227
|
-
attrs: { jid }
|
|
228
|
-
}))
|
|
229
|
-
}
|
|
230
|
-
]);
|
|
231
|
-
const node = (0, WABinary_1.getBinaryNodeChild)(result, action);
|
|
232
|
-
const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(node, 'participant');
|
|
233
|
-
return participantsAffected.map(p => {
|
|
234
|
-
return { status: p.attrs.error || '200', jid: p.attrs.jid, content: p };
|
|
235
|
-
});
|
|
236
|
-
},
|
|
237
|
-
groupUpdateDescription: async (jid, description) => {
|
|
238
|
-
const metadata = await groupMetadata(jid);
|
|
239
|
-
const prev = metadata.descId ?? null;
|
|
240
|
-
await groupQuery(jid, 'set', [
|
|
241
|
-
{
|
|
242
|
-
tag: 'description',
|
|
243
|
-
attrs: {
|
|
244
|
-
...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
|
|
245
|
-
...(prev ? { prev } : {})
|
|
246
|
-
},
|
|
247
|
-
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
248
|
-
}
|
|
249
|
-
]);
|
|
250
|
-
},
|
|
251
|
-
groupInviteCode: async (jid) => {
|
|
252
|
-
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
253
|
-
const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
|
|
254
|
-
return inviteNode?.attrs.code;
|
|
255
|
-
},
|
|
256
|
-
groupRevokeInvite: async (jid) => {
|
|
257
|
-
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
258
|
-
const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
|
|
259
|
-
return inviteNode?.attrs.code;
|
|
260
|
-
},
|
|
261
|
-
groupAcceptInvite: async (code) => {
|
|
262
|
-
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
263
|
-
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
264
|
-
return result?.attrs.jid;
|
|
265
|
-
},
|
|
266
|
-
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
267
|
-
const result = await groupQuery(groupJid, 'set', [
|
|
268
|
-
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
269
|
-
]);
|
|
270
|
-
return !!result;
|
|
271
|
-
},
|
|
272
|
-
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
273
|
-
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
274
|
-
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
275
|
-
{
|
|
276
|
-
tag: 'accept',
|
|
277
|
-
attrs: {
|
|
278
|
-
code: inviteMessage.inviteCode,
|
|
279
|
-
expiration: inviteMessage.inviteExpiration.toString(),
|
|
280
|
-
admin: key.remoteJid
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
]);
|
|
284
|
-
if (key.id) {
|
|
285
|
-
inviteMessage = index_js_1.proto.Message.GroupInviteMessage.fromObject(inviteMessage);
|
|
286
|
-
inviteMessage.inviteExpiration = 0;
|
|
287
|
-
inviteMessage.inviteCode = '';
|
|
288
|
-
ev.emit('messages.update', [
|
|
289
|
-
{
|
|
290
|
-
key,
|
|
291
|
-
update: {
|
|
292
|
-
message: {
|
|
293
|
-
groupInviteMessage: inviteMessage
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
]);
|
|
298
|
-
}
|
|
299
|
-
await upsertMessage({
|
|
300
|
-
key: {
|
|
301
|
-
remoteJid: inviteMessage.groupJid,
|
|
302
|
-
id: (0, Utils_1.generateMessageIDV2)(sock.user?.id),
|
|
303
|
-
fromMe: false,
|
|
304
|
-
participant: key.remoteJid
|
|
305
|
-
},
|
|
306
|
-
messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
307
|
-
messageStubParameters: [JSON.stringify(authState.creds.me)],
|
|
308
|
-
participant: key.remoteJid,
|
|
309
|
-
messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
|
|
310
|
-
}, 'notify');
|
|
311
|
-
return results.attrs.from;
|
|
312
|
-
}),
|
|
313
|
-
groupGetInviteInfo: async (code) => {
|
|
314
|
-
const results = await groupQuery('@g.us', 'get', [{ tag: 'invite', attrs: { code } }]);
|
|
315
|
-
return (0, exports.extractGroupMetadata)(results);
|
|
316
|
-
},
|
|
317
|
-
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
318
|
-
const content = ephemeralExpiration
|
|
319
|
-
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
320
|
-
: { tag: 'not_ephemeral', attrs: {} };
|
|
321
|
-
await groupQuery(jid, 'set', [content]);
|
|
322
|
-
},
|
|
323
|
-
groupSettingUpdate: async (jid, setting) => {
|
|
324
|
-
await groupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
325
|
-
},
|
|
326
|
-
groupMemberAddMode: async (jid, mode) => {
|
|
327
|
-
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
328
|
-
},
|
|
329
|
-
groupJoinApprovalMode: async (jid, mode) => {
|
|
330
|
-
await groupQuery(jid, 'set', [
|
|
331
|
-
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
332
|
-
]);
|
|
333
|
-
},
|
|
334
|
-
groupGetPastParticipants: async (jid) => {
|
|
335
|
-
const result = await groupQuery(jid, 'get', [{ tag: 'past_participants', attrs: {} }]);
|
|
336
|
-
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'past_participants');
|
|
337
|
-
if (!node)
|
|
338
|
-
return [];
|
|
339
|
-
const participants = (0, WABinary_1.getBinaryNodeChildren)(node, 'past_participant');
|
|
340
|
-
return participants.map(p => ({
|
|
341
|
-
jid: p.attrs.jid,
|
|
342
|
-
leaveReason: p.attrs.reason,
|
|
343
|
-
leaveTimestamp: p.attrs.t ? Number(p.attrs.t) : undefined
|
|
344
|
-
}));
|
|
345
|
-
},
|
|
346
|
-
groupCreateSubgroup: async (communityJid, subject, participants = []) => {
|
|
347
|
-
const key = (0, Utils_1.generateMessageIDV2)();
|
|
348
|
-
const result = await groupQuery('@g.us', 'set', [
|
|
349
|
-
{
|
|
350
|
-
tag: 'create',
|
|
351
|
-
attrs: { subject, key, parent_group_id: communityJid },
|
|
352
|
-
content: participants.map(jid => ({ tag: 'participant', attrs: { jid } }))
|
|
353
|
-
}
|
|
354
|
-
]);
|
|
355
|
-
return (0, exports.extractGroupMetadata)(result);
|
|
356
|
-
},
|
|
357
|
-
groupLinkToCommunity: async (communityJid, groupJid) => {
|
|
358
|
-
await groupQuery(communityJid, 'set', [
|
|
359
|
-
{
|
|
360
|
-
tag: 'links',
|
|
361
|
-
attrs: {},
|
|
362
|
-
content: [
|
|
363
|
-
{ tag: 'link', attrs: { link_type: 'sub_group' }, content: [{ tag: 'group', attrs: { jid: groupJid } }] }
|
|
364
|
-
]
|
|
365
|
-
}
|
|
366
|
-
]);
|
|
367
|
-
},
|
|
368
|
-
groupUnlinkFromCommunity: async (communityJid, groupJid) => {
|
|
369
|
-
await groupQuery(communityJid, 'set', [
|
|
370
|
-
{
|
|
371
|
-
tag: 'unlinks',
|
|
372
|
-
attrs: {},
|
|
373
|
-
content: [
|
|
374
|
-
{ tag: 'unlink', attrs: { link_type: 'sub_group' }, content: [{ tag: 'group', attrs: { jid: groupJid } }] }
|
|
375
|
-
]
|
|
376
|
-
}
|
|
377
|
-
]);
|
|
378
|
-
},
|
|
379
|
-
groupSetMemberLabel: async (jid, participantJid, label) => {
|
|
380
|
-
await groupQuery(jid, 'set', [
|
|
381
|
-
{
|
|
382
|
-
tag: 'member_add_mode',
|
|
383
|
-
attrs: {},
|
|
384
|
-
content: [
|
|
385
|
-
{
|
|
386
|
-
tag: 'participant',
|
|
387
|
-
attrs: { jid: participantJid, label: label || '' }
|
|
388
|
-
}
|
|
389
|
-
]
|
|
390
|
-
}
|
|
391
|
-
]);
|
|
392
|
-
},
|
|
393
|
-
groupGetLinkedSubgroups: async (communityJid) => {
|
|
394
|
-
const result = await groupQuery(communityJid, 'get', [{ tag: 'links', attrs: { link_type: 'sub_group' } }]);
|
|
395
|
-
const linksNode = (0, WABinary_1.getBinaryNodeChild)(result, 'links');
|
|
396
|
-
if (!linksNode)
|
|
397
|
-
return [];
|
|
398
|
-
return (0, WABinary_1.getBinaryNodeChildren)(linksNode, 'link')
|
|
399
|
-
.map(link => {
|
|
400
|
-
const group = (0, WABinary_1.getBinaryNodeChild)(link, 'group');
|
|
401
|
-
return { jid: group?.attrs?.jid, linkType: link.attrs?.link_type };
|
|
402
|
-
})
|
|
403
|
-
.filter(l => !!l.jid);
|
|
404
|
-
},
|
|
405
|
-
groupFetchAllParticipating,
|
|
406
|
-
groupQueryInfo: jid => mexQuery({ group_id: jid }, GROUP_MEX_QUERY_IDS.QUERY_INFO, 'xwa2_group_query_by_id'),
|
|
407
|
-
groupQueryInfoByCode: code => mexQuery({ group_input: { invite_code: code } }, GROUP_MEX_QUERY_IDS.QUERY_INFO_BY_CODE, 'xwa2_group_query_by_id'),
|
|
408
|
-
groupQueryBatch: jids => mexQuery({ groups_input: jids.map(group_id => ({ group_id })) }, GROUP_MEX_QUERY_IDS.QUERY_BATCH, 'xwa2_group_query_batch'),
|
|
409
|
-
groupQueryInviteLink: jid => mexQuery({ group_input: { group_id: jid } }, GROUP_MEX_QUERY_IDS.QUERY_INVITE_LINK, 'xwa2_group_query_by_id'),
|
|
410
|
-
groupQueryParticipating: () => mexQuery({}, GROUP_MEX_QUERY_IDS.QUERY_PARTICIPATING, 'xwa2_group_query_participating'),
|
|
411
|
-
groupQuerySuggested: communityJid => mexQuery({ group_input: { group_id: communityJid } }, GROUP_MEX_QUERY_IDS.QUERY_SUGGESTED, 'xwa2_group_query_by_id'),
|
|
412
|
-
groupQueryLinked: jid => mexQuery({ group_input: { group_id: jid } }, GROUP_MEX_QUERY_IDS.QUERY_LINKED, 'xwa2_group_query_by_id'),
|
|
413
|
-
groupQuerySubgroups: communityJid => mexQuery({ group_input: { group_id: communityJid } }, GROUP_MEX_QUERY_IDS.QUERY_SUBGROUPS, 'xwa2_group_query_by_id'),
|
|
414
|
-
groupAddParticipantsMex: (jid, participants) => mexQuery({ group_id: jid, participants: participants.map(p => ({ user_jid: p })) }, GROUP_MEX_QUERY_IDS.ADD_PARTICIPANTS_V2, 'xwa2_group_add_participants'),
|
|
415
|
-
groupSetProperty: (jid, property, value) => mexQuery({ group_id: jid, [property]: value }, GROUP_MEX_QUERY_IDS.SET_PROPERTY, 'xwa2_group_set_property'),
|
|
416
|
-
groupResetInviteLinkMex: jid => mexQuery({ group_jid: jid }, GROUP_MEX_QUERY_IDS.RESET_INVITE_LINK, 'xwa2_group_reset_invite_link'),
|
|
417
|
-
groupCreateMex: (subject, participantJids) => mexQuery({ input: { subject, participants: participantJids.map(jid => ({ jid })) } }, GROUP_MEX_QUERY_IDS.CREATE_GROUP, 'xwa2_group_create'),
|
|
418
|
-
groupAllowNonAdminCreation: (communityJid, allow) => mexQuery({ group_jid: communityJid, allow_non_admin_sub_group_creation: allow }, GROUP_MEX_QUERY_IDS.ALLOW_NON_ADMIN_GROUP_CREATION, 'xwa2_group_allow_non_admin_creation'),
|
|
419
|
-
groupGetInviteInfo: inviteCode => mexQuery({ invite_code: inviteCode }, GROUP_MEX_QUERY_IDS.GET_INVITE_INFO, 'xwa2_group_get_invite_info'),
|
|
420
|
-
groupPreRegAddRequests: jid => mexQuery({ group_jid: jid }, GROUP_MEX_QUERY_IDS.GET_PRE_REG_ADD_REQUESTS, 'xwa2_group_pre_reg_add_requests'),
|
|
421
|
-
groupSuggestedContacts: jid => mexQuery({ group_jid: jid }, GROUP_MEX_QUERY_IDS.GET_SUGGESTED_CONTACTS, 'xwa2_group_suggested_contacts'),
|
|
422
|
-
groupStoreInvitesSms: (jid, invites) => mexQuery({ group_jid: jid, invites: invites.map(({ phone, inviteCode }) => ({ phone, invite_code: inviteCode })) }, GROUP_MEX_QUERY_IDS.STORE_INVITES_SMS, 'xwa2_group_store_invites_sms'),
|
|
423
|
-
groupLogServerSentInvite: (jid, inviteCode) => mexQuery({ group_jid: jid, invite_code: inviteCode }, GROUP_MEX_QUERY_IDS.LOG_SERVER_SENT_INVITE, 'xwa2_group_log_server_sent_invite'),
|
|
424
|
-
queryOnlineStatus: jids => mexQuery({ jids }, GROUP_MEX_QUERY_IDS.QUERY_ONLINE_STATUS, 'xwa2_query_online_status'),
|
|
425
|
-
queryOnlineStatusLastSeen: jids => mexQuery({ jids }, GROUP_MEX_QUERY_IDS.QUERY_ONLINE_STATUS_LAST_SEEN, 'xwa2_query_online_status_last_seen'),
|
|
426
|
-
GROUP_MEX_QUERY_IDS
|
|
427
|
-
};
|
|
428
|
-
};
|
|
429
|
-
exports.makeGroupsSocket = makeGroupsSocket;
|
|
430
|
-
const extractGroupMetadata = result => {
|
|
431
|
-
const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
|
|
432
|
-
const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
|
|
433
|
-
let desc;
|
|
434
|
-
let descId;
|
|
435
|
-
let descOwner;
|
|
436
|
-
let descOwnerPn;
|
|
437
|
-
let descOwnerUsername;
|
|
438
|
-
let descTime;
|
|
439
|
-
if (descChild) {
|
|
440
|
-
desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
|
|
441
|
-
descOwner = descChild.attrs.participant ? (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant) : undefined;
|
|
442
|
-
descOwnerPn = descChild.attrs.participant_pn
|
|
443
|
-
? (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn)
|
|
444
|
-
: undefined;
|
|
445
|
-
descOwnerUsername = descChild.attrs.participant_username || undefined;
|
|
446
|
-
descTime = +descChild.attrs.t;
|
|
447
|
-
descId = descChild.attrs.id;
|
|
448
|
-
}
|
|
449
|
-
const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
|
|
450
|
-
const eph = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')?.attrs.expiration;
|
|
451
|
-
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
|
|
452
|
-
const linkedParentNode = (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent');
|
|
453
|
-
const communityMemberAddGroupNode = (0, WABinary_1.getBinaryNodeChild)(group, 'allow_non_admin_sub_group_creation');
|
|
454
|
-
const subGroupVisibilityNode = (0, WABinary_1.getBinaryNodeChild)(group, 'sub_groups_list');
|
|
455
|
-
const membershipApprovalNode = (0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode');
|
|
456
|
-
const metadata = {
|
|
457
|
-
id: groupId,
|
|
458
|
-
notify: group.attrs.notify,
|
|
459
|
-
addressingMode: group.attrs.addressing_mode === 'lid' ? Types_1.WAMessageAddressingMode.LID : Types_1.WAMessageAddressingMode.PN,
|
|
460
|
-
subject: group.attrs.subject,
|
|
461
|
-
subjectOwner: group.attrs.s_o,
|
|
462
|
-
subjectOwnerPn: group.attrs.s_o_pn,
|
|
463
|
-
subjectOwnerUsername: group.attrs.s_o_username,
|
|
464
|
-
subjectTime: +group.attrs.s_t,
|
|
465
|
-
size: group.attrs.size ? +group.attrs.size : (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
|
|
466
|
-
creation: +group.attrs.creation,
|
|
467
|
-
owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,
|
|
468
|
-
ownerPn: group.attrs.creator_pn ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn) : undefined,
|
|
469
|
-
ownerUsername: group.attrs.creator_username || undefined,
|
|
470
|
-
owner_country_code: group.attrs.creator_country_code,
|
|
471
|
-
desc,
|
|
472
|
-
descId,
|
|
473
|
-
descOwner,
|
|
474
|
-
descOwnerPn,
|
|
475
|
-
descOwnerUsername,
|
|
476
|
-
descTime,
|
|
477
|
-
linkedParent: linkedParentNode?.attrs.jid || undefined,
|
|
478
|
-
restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
|
|
479
|
-
announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
|
|
480
|
-
isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
|
|
481
|
-
isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
|
|
482
|
-
joinApprovalMode: !!membershipApprovalNode,
|
|
483
|
-
memberAddMode,
|
|
484
|
-
memberShareHistoryMode: (0, WABinary_1.getBinaryNodeChildString)(group, 'member_share_group_history_mode') || undefined,
|
|
485
|
-
memberLinkMode: (0, WABinary_1.getBinaryNodeChildString)(group, 'member_link_mode') || undefined,
|
|
486
|
-
limitSharing: !!(0, WABinary_1.getBinaryNodeChild)(group, 'limit_sharing_enabled'),
|
|
487
|
-
communityMemberAddGroupMode: communityMemberAddGroupNode?.attrs.state || undefined,
|
|
488
|
-
capiCreatedGroup: group.attrs.capi_created === 'true' || undefined,
|
|
489
|
-
appealStatus: group.attrs.appeal_status || undefined,
|
|
490
|
-
isSubGroupHidden: group.attrs.sub_group_visibility === 'hidden' || undefined,
|
|
491
|
-
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
|
492
|
-
return {
|
|
493
|
-
id: attrs.jid,
|
|
494
|
-
phoneNumber: (0, WABinary_1.isLidUser)(attrs.jid) && (0, WABinary_1.isPnUser)(attrs.phone_number)
|
|
495
|
-
? attrs.phone_number
|
|
496
|
-
: undefined,
|
|
497
|
-
lid: (0, WABinary_1.isPnUser)(attrs.jid) && (0, WABinary_1.isLidUser)(attrs.lid) ? attrs.lid : undefined,
|
|
498
|
-
username: attrs.participant_username || attrs.username || undefined,
|
|
499
|
-
admin: attrs.type || null,
|
|
500
|
-
memberLabel: attrs.label || undefined,
|
|
501
|
-
memberLabelTimestamp: attrs.label_ts ? +attrs.label_ts : undefined,
|
|
502
|
-
isBanned: attrs.error === '403' || attrs.ban === 'true' || undefined
|
|
503
|
-
};
|
|
504
|
-
}),
|
|
505
|
-
bannedParticipants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant')
|
|
506
|
-
.filter(({ attrs }) => attrs.error === '403' || attrs.ban === 'true')
|
|
507
|
-
.map(({ attrs }) => ({
|
|
508
|
-
id: attrs.jid,
|
|
509
|
-
phoneNumber: attrs.phone_number || undefined,
|
|
510
|
-
lid: attrs.lid || undefined
|
|
511
|
-
})),
|
|
512
|
-
ephemeralDuration: eph ? +eph : undefined
|
|
513
|
-
};
|
|
514
|
-
return metadata;
|
|
515
|
-
};
|
|
516
|
-
exports.extractGroupMetadata = extractGroupMetadata;
|
package/src/Socket/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
const Defaults_1 = require('../Defaults');
|
|
4
|
-
const communities_1 = require('./communities');
|
|
5
|
-
const { makeInteropSocket } = require('./interop');
|
|
6
|
-
const { makePrivacySocket } = require('./privacy');
|
|
7
|
-
const { makeRegistrationSocket } = require('./registration');
|
|
8
|
-
const { makeManagedAccountSocket } = require('./managed-account');
|
|
9
|
-
const { makeGraphQLSocket } = require('./graphql');
|
|
10
|
-
const { wrapSocket: _wrapSocket } = require('../antiban');
|
|
11
|
-
const { attachTextRouter } = require('./text-router');
|
|
12
|
-
const makeWASocket = config => {
|
|
13
|
-
const userExplicitSyncFlag = typeof config?.syncFullHistory === 'boolean';
|
|
14
|
-
const initialFullSyncDone = !!config?.auth?.creds?.initialFullSyncDone;
|
|
15
|
-
const effectiveSyncFullHistory = userExplicitSyncFlag ? config.syncFullHistory : !initialFullSyncDone;
|
|
16
|
-
const newConfig = {
|
|
17
|
-
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
18
|
-
...config,
|
|
19
|
-
syncFullHistory: effectiveSyncFullHistory
|
|
20
|
-
};
|
|
21
|
-
newConfig.logger?.debug?.({ initialFullSyncDone, effectiveSyncFullHistory, userExplicitSyncFlag }, 'computed syncFullHistory policy');
|
|
22
|
-
const baseSock = (0, communities_1.makeCommunitiesSocket)(newConfig);
|
|
23
|
-
const interopSock = makeInteropSocket(baseSock);
|
|
24
|
-
const privacySock = makePrivacySocket(interopSock);
|
|
25
|
-
const registrationSock = makeRegistrationSocket(privacySock);
|
|
26
|
-
const managedSock = makeManagedAccountSocket(registrationSock);
|
|
27
|
-
const sock = makeGraphQLSocket(managedSock);
|
|
28
|
-
const finalSock = _wrapSocket && config?.antiban !== false ? _wrapSocket(sock, config?.antiban || 'aggressive') : sock;
|
|
29
|
-
return attachTextRouter(finalSock);
|
|
30
|
-
};
|
|
31
|
-
exports.default = makeWASocket;
|