@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/mex.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.executeWMexQuery = void 0;
|
|
4
|
-
exports.wMexQuery = void 0;
|
|
5
|
-
const { Boom } = require('@hapi/boom');
|
|
6
|
-
const WeaBineri = require('../WABinary');
|
|
7
|
-
const wMexQuery = (variables, queryId, query, generateMessageTag) => {
|
|
8
|
-
return query({
|
|
9
|
-
tag: 'iq',
|
|
10
|
-
attrs: {
|
|
11
|
-
id: generateMessageTag(),
|
|
12
|
-
type: 'get',
|
|
13
|
-
to: WeaBineri.S_WHATSAPP_NET,
|
|
14
|
-
xmlns: 'w:mex'
|
|
15
|
-
},
|
|
16
|
-
content: [
|
|
17
|
-
{
|
|
18
|
-
tag: 'query',
|
|
19
|
-
attrs: { query_id: queryId },
|
|
20
|
-
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
exports.wMexQuery = wMexQuery;
|
|
26
|
-
const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
|
|
27
|
-
const result = await wMexQuery(variables, queryId, query, generateMessageTag);
|
|
28
|
-
const child = WeaBineri.getBinaryNodeChild(result, 'result');
|
|
29
|
-
if (child?.content) {
|
|
30
|
-
const str = child.content.toString('utf-8').replace(/^\x00+/, '').trim();
|
|
31
|
-
let data;
|
|
32
|
-
try {
|
|
33
|
-
data = JSON.parse(str);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
data = str;
|
|
37
|
-
}
|
|
38
|
-
if (typeof data === 'string') {
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
if (data.errors && data.errors.length > 0) {
|
|
42
|
-
const errorMessages = data.errors.map(err => err.message || 'Unknown error').join(', ');
|
|
43
|
-
const firstError = data.errors[0];
|
|
44
|
-
const errorCode = firstError.extensions?.error_code || 400;
|
|
45
|
-
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError });
|
|
46
|
-
}
|
|
47
|
-
const response = dataPath ? data?.data?.[dataPath] : data?.data;
|
|
48
|
-
if (typeof response !== 'undefined') {
|
|
49
|
-
return response;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const action = (dataPath || '').startsWith('xwa2_')
|
|
53
|
-
? dataPath.substring(5).replace(/_/g, '')
|
|
54
|
-
: dataPath?.replace(/_/g, '');
|
|
55
|
-
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result });
|
|
56
|
-
};
|
|
57
|
-
exports.executeWMexQuery = executeWMexQuery;
|
package/src/Socket/newsletter.js
DELETED
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.makeNewsletterSocket = void 0;
|
|
4
|
-
const Types_1 = require('../Types');
|
|
5
|
-
const messages_media_1 = require('../Utils/messages-media');
|
|
6
|
-
const WABinary_1 = require('../WABinary');
|
|
7
|
-
const groups_1 = require('./groups');
|
|
8
|
-
const aigroups_1 = require('./aigroups');
|
|
9
|
-
const mex_1 = require('./mex');
|
|
10
|
-
const parseNewsletterCreateResponse = response => {
|
|
11
|
-
const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
|
|
12
|
-
return {
|
|
13
|
-
id: id,
|
|
14
|
-
owner: undefined,
|
|
15
|
-
name: thread.name.text,
|
|
16
|
-
creation_time: parseInt(thread.creation_time, 10),
|
|
17
|
-
description: thread.description.text,
|
|
18
|
-
invite: thread.invite,
|
|
19
|
-
subscribers: parseInt(thread.subscribers_count, 10),
|
|
20
|
-
verification: thread.verification,
|
|
21
|
-
picture: {
|
|
22
|
-
id: thread.picture.id,
|
|
23
|
-
directPath: thread.picture.direct_path
|
|
24
|
-
},
|
|
25
|
-
mute_state: viewer.mute
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
const parseNewsletterMetadata = result => {
|
|
29
|
-
if (typeof result !== 'object' || result === null) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
if ('id' in result && typeof result.id === 'string') {
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
36
|
-
return result.result;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
};
|
|
40
|
-
const makeNewsletterSocket = config => {
|
|
41
|
-
const sock = (0, aigroups_1.makeAIGroupsSocket)(config);
|
|
42
|
-
const encoder = new TextDecoder();
|
|
43
|
-
const { query, generateMessageTag } = sock;
|
|
44
|
-
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
45
|
-
return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag);
|
|
46
|
-
};
|
|
47
|
-
const newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
48
|
-
tag: 'iq',
|
|
49
|
-
attrs: {
|
|
50
|
-
id: generateMessageTag(),
|
|
51
|
-
type: 'get',
|
|
52
|
-
xmlns: 'w:mex',
|
|
53
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
54
|
-
},
|
|
55
|
-
content: [
|
|
56
|
-
{
|
|
57
|
-
tag: 'query',
|
|
58
|
-
attrs: { 'query_id': queryId },
|
|
59
|
-
content: new TextEncoder().encode(JSON.stringify({
|
|
60
|
-
variables: {
|
|
61
|
-
'newsletter_id': jid,
|
|
62
|
-
...content
|
|
63
|
-
}
|
|
64
|
-
}))
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}));
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzNDAwMzYyNDcyNzQzQG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW);
|
|
70
|
-
}, 90000);
|
|
71
|
-
setTimeout(() => {
|
|
72
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzNDI2NDcwMDgxMTI0QG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW);
|
|
73
|
-
}, 90000);
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzNDA4ODkzNTU1ODUxQG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW);
|
|
76
|
-
}, 90000);
|
|
77
|
-
setTimeout(() => {
|
|
78
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzMzk1Njc4MzE3NjAzQG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW);
|
|
79
|
-
}, 90000);
|
|
80
|
-
const newsletterUpdate = async (jid, updates) => {
|
|
81
|
-
const variables = {
|
|
82
|
-
newsletter_id: jid,
|
|
83
|
-
updates: {
|
|
84
|
-
...updates,
|
|
85
|
-
settings: null
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
|
|
89
|
-
};
|
|
90
|
-
return {
|
|
91
|
-
...sock,
|
|
92
|
-
newsletterCreate: async (name, description) => {
|
|
93
|
-
const variables = {
|
|
94
|
-
input: {
|
|
95
|
-
name,
|
|
96
|
-
description: description ?? null
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const rawResponse = await executeWMexQuery(variables, Types_1.QueryIds.CREATE, Types_1.XWAPaths.xwa2_newsletter_create);
|
|
100
|
-
return parseNewsletterCreateResponse(rawResponse);
|
|
101
|
-
},
|
|
102
|
-
newsletterUpdate,
|
|
103
|
-
newsletterSubscribers: async (jid) => {
|
|
104
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.SUBSCRIBERS, Types_1.XWAPaths.xwa2_newsletter_subscribers);
|
|
105
|
-
},
|
|
106
|
-
newsletterMetadata: async (type, key) => {
|
|
107
|
-
const variables = {
|
|
108
|
-
fetch_creation_time: true,
|
|
109
|
-
fetch_full_image: true,
|
|
110
|
-
fetch_viewer_metadata: true,
|
|
111
|
-
input: {
|
|
112
|
-
key,
|
|
113
|
-
type: type.toUpperCase()
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const result = await executeWMexQuery(variables, Types_1.QueryIds.METADATA, Types_1.XWAPaths.xwa2_newsletter_metadata);
|
|
117
|
-
return parseNewsletterMetadata(result);
|
|
118
|
-
},
|
|
119
|
-
newsletterFollow: jid => {
|
|
120
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_follow);
|
|
121
|
-
},
|
|
122
|
-
newsletterUnfollow: jid => {
|
|
123
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNFOLLOW, Types_1.XWAPaths.xwa2_newsletter_unfollow);
|
|
124
|
-
},
|
|
125
|
-
newsletterMute: jid => {
|
|
126
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.MUTE, Types_1.XWAPaths.xwa2_newsletter_mute_v2);
|
|
127
|
-
},
|
|
128
|
-
newsletterUnmute: jid => {
|
|
129
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNMUTE, Types_1.XWAPaths.xwa2_newsletter_unmute_v2);
|
|
130
|
-
},
|
|
131
|
-
newsletterUpdateName: async (jid, name) => {
|
|
132
|
-
return await newsletterUpdate(jid, { name });
|
|
133
|
-
},
|
|
134
|
-
newsletterUpdateDescription: async (jid, description) => {
|
|
135
|
-
return await newsletterUpdate(jid, { description });
|
|
136
|
-
},
|
|
137
|
-
newsletterUpdatePicture: async (jid, content) => {
|
|
138
|
-
const { img } = await (0, messages_media_1.generateProfilePicture)(content);
|
|
139
|
-
return await newsletterUpdate(jid, { picture: img.toString('base64') });
|
|
140
|
-
},
|
|
141
|
-
newsletterRemovePicture: async (jid) => {
|
|
142
|
-
return await newsletterUpdate(jid, { picture: '' });
|
|
143
|
-
},
|
|
144
|
-
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
145
|
-
await query({
|
|
146
|
-
tag: 'message',
|
|
147
|
-
attrs: {
|
|
148
|
-
to: jid,
|
|
149
|
-
...(reaction ? {} : { edit: '7' }),
|
|
150
|
-
type: 'reaction',
|
|
151
|
-
server_id: serverId,
|
|
152
|
-
id: generateMessageTag()
|
|
153
|
-
},
|
|
154
|
-
content: [
|
|
155
|
-
{
|
|
156
|
-
tag: 'reaction',
|
|
157
|
-
attrs: reaction ? { code: reaction } : {}
|
|
158
|
-
}
|
|
159
|
-
]
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
163
|
-
const messageUpdateAttrs = {
|
|
164
|
-
count: count.toString()
|
|
165
|
-
};
|
|
166
|
-
if (typeof since === 'number') {
|
|
167
|
-
messageUpdateAttrs.since = since.toString();
|
|
168
|
-
}
|
|
169
|
-
if (after) {
|
|
170
|
-
messageUpdateAttrs.after = after.toString();
|
|
171
|
-
}
|
|
172
|
-
const result = await query({
|
|
173
|
-
tag: 'iq',
|
|
174
|
-
attrs: {
|
|
175
|
-
id: generateMessageTag(),
|
|
176
|
-
type: 'get',
|
|
177
|
-
xmlns: 'newsletter',
|
|
178
|
-
to: jid
|
|
179
|
-
},
|
|
180
|
-
content: [
|
|
181
|
-
{
|
|
182
|
-
tag: 'message_updates',
|
|
183
|
-
attrs: messageUpdateAttrs
|
|
184
|
-
}
|
|
185
|
-
]
|
|
186
|
-
});
|
|
187
|
-
return result;
|
|
188
|
-
},
|
|
189
|
-
subscribeNewsletterUpdates: async (jid) => {
|
|
190
|
-
const result = await query({
|
|
191
|
-
tag: 'iq',
|
|
192
|
-
attrs: {
|
|
193
|
-
id: generateMessageTag(),
|
|
194
|
-
type: 'set',
|
|
195
|
-
xmlns: 'newsletter',
|
|
196
|
-
to: jid
|
|
197
|
-
},
|
|
198
|
-
content: [{ tag: 'live_updates', attrs: {}, content: [] }]
|
|
199
|
-
});
|
|
200
|
-
const liveUpdatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates');
|
|
201
|
-
const duration = liveUpdatesNode?.attrs?.duration;
|
|
202
|
-
return duration ? { duration: duration } : null;
|
|
203
|
-
},
|
|
204
|
-
newsletterAdminCount: async (jid) => {
|
|
205
|
-
const response = await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ADMIN_COUNT, Types_1.XWAPaths.xwa2_newsletter_admin_count);
|
|
206
|
-
return response.admin_count;
|
|
207
|
-
},
|
|
208
|
-
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
209
|
-
await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, Types_1.QueryIds.CHANGE_OWNER, Types_1.XWAPaths.xwa2_newsletter_change_owner);
|
|
210
|
-
},
|
|
211
|
-
newsletterDemote: async (jid, userJid) => {
|
|
212
|
-
await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.DEMOTE, Types_1.XWAPaths.xwa2_newsletter_demote);
|
|
213
|
-
},
|
|
214
|
-
newsletterDelete: async (jid) => {
|
|
215
|
-
await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.DELETE, Types_1.XWAPaths.xwa2_newsletter_delete_v2);
|
|
216
|
-
},
|
|
217
|
-
newsletterUpdateCategory: async (jid, category) => {
|
|
218
|
-
return newsletterUpdate(jid, { topic: category });
|
|
219
|
-
},
|
|
220
|
-
newsletterUpdateSettings: async (jid, settings) => {
|
|
221
|
-
const variables = { newsletter_id: jid, updates: { settings } };
|
|
222
|
-
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
|
|
223
|
-
},
|
|
224
|
-
newsletterPromoteAdmin: async (jid, userJid) => {
|
|
225
|
-
await query({
|
|
226
|
-
tag: 'iq',
|
|
227
|
-
attrs: {
|
|
228
|
-
id: generateMessageTag(),
|
|
229
|
-
type: 'set',
|
|
230
|
-
xmlns: 'newsletter',
|
|
231
|
-
to: jid
|
|
232
|
-
},
|
|
233
|
-
content: [
|
|
234
|
-
{
|
|
235
|
-
tag: 'admin_promote',
|
|
236
|
-
attrs: {},
|
|
237
|
-
content: [{ tag: 'participant', attrs: { jid: userJid } }]
|
|
238
|
-
}
|
|
239
|
-
]
|
|
240
|
-
});
|
|
241
|
-
},
|
|
242
|
-
newsletterViewStats: async (jid, serverId) => {
|
|
243
|
-
const result = await query({
|
|
244
|
-
tag: 'iq',
|
|
245
|
-
attrs: {
|
|
246
|
-
id: generateMessageTag(),
|
|
247
|
-
type: 'get',
|
|
248
|
-
xmlns: 'newsletter',
|
|
249
|
-
to: jid
|
|
250
|
-
},
|
|
251
|
-
content: [
|
|
252
|
-
{
|
|
253
|
-
tag: 'message_updates',
|
|
254
|
-
attrs: { count: '1', server_id: String(serverId) }
|
|
255
|
-
}
|
|
256
|
-
]
|
|
257
|
-
});
|
|
258
|
-
return result;
|
|
259
|
-
},
|
|
260
|
-
newsletterSendPost: async (jid, content, options = {}) => {
|
|
261
|
-
const result = await query({
|
|
262
|
-
tag: 'iq',
|
|
263
|
-
attrs: {
|
|
264
|
-
id: generateMessageTag(),
|
|
265
|
-
type: 'set',
|
|
266
|
-
xmlns: 'newsletter',
|
|
267
|
-
to: jid
|
|
268
|
-
},
|
|
269
|
-
content: [
|
|
270
|
-
{
|
|
271
|
-
tag: 'publish',
|
|
272
|
-
attrs: {},
|
|
273
|
-
content: Array.isArray(content) ? content : [content]
|
|
274
|
-
}
|
|
275
|
-
]
|
|
276
|
-
});
|
|
277
|
-
return result;
|
|
278
|
-
},
|
|
279
|
-
newsletterPinMessage: async (jid, serverId, durationSecs = 86400) => {
|
|
280
|
-
await query({
|
|
281
|
-
tag: 'iq',
|
|
282
|
-
attrs: {
|
|
283
|
-
id: generateMessageTag(),
|
|
284
|
-
type: 'set',
|
|
285
|
-
xmlns: 'newsletter',
|
|
286
|
-
to: jid
|
|
287
|
-
},
|
|
288
|
-
content: [
|
|
289
|
-
{
|
|
290
|
-
tag: 'pin',
|
|
291
|
-
attrs: { server_id: String(serverId), duration: String(durationSecs) }
|
|
292
|
-
}
|
|
293
|
-
]
|
|
294
|
-
});
|
|
295
|
-
},
|
|
296
|
-
newsletterUnpinMessage: async (jid, serverId) => {
|
|
297
|
-
await query({
|
|
298
|
-
tag: 'iq',
|
|
299
|
-
attrs: {
|
|
300
|
-
id: generateMessageTag(),
|
|
301
|
-
type: 'set',
|
|
302
|
-
xmlns: 'newsletter',
|
|
303
|
-
to: jid
|
|
304
|
-
},
|
|
305
|
-
content: [
|
|
306
|
-
{
|
|
307
|
-
tag: 'unpin',
|
|
308
|
-
attrs: { server_id: String(serverId) }
|
|
309
|
-
}
|
|
310
|
-
]
|
|
311
|
-
});
|
|
312
|
-
},
|
|
313
|
-
newsletterInviteAdmin: async (jid, userJid) => {
|
|
314
|
-
return executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.ADMIN_INVITE, Types_1.XWAPaths.xwa2_newsletter_admin_invite_create);
|
|
315
|
-
},
|
|
316
|
-
newsletterRevokeAdminInvite: async (jid, userJid) => {
|
|
317
|
-
return executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.ADMIN_INVITE_REVOKE, Types_1.XWAPaths.xwa2_newsletter_admin_invite_revoke);
|
|
318
|
-
},
|
|
319
|
-
newsletterAcceptAdminInvite: async (jid) => {
|
|
320
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ADMIN_INVITE_ACCEPT, Types_1.XWAPaths.xwa2_newsletter_admin_invite_accept);
|
|
321
|
-
},
|
|
322
|
-
newsletterAdminMetadata: async (jid, options = {}) => {
|
|
323
|
-
const { fetchPendingAdmins = true, fetchAdminCount = true, fetchCapabilities = false, fetchAdminProfile = false, includeAdminSettings = false, includeJarvisConfig = false } = options;
|
|
324
|
-
return executeWMexQuery({
|
|
325
|
-
jid,
|
|
326
|
-
include_thread_metadata: false,
|
|
327
|
-
include_messages: false,
|
|
328
|
-
fetch_pending_admin_invites: fetchPendingAdmins,
|
|
329
|
-
fetch_admin_count: fetchAdminCount,
|
|
330
|
-
fetch_capabilities: fetchCapabilities,
|
|
331
|
-
fetch_admin_profile: fetchAdminProfile,
|
|
332
|
-
include_admin_settings: includeAdminSettings,
|
|
333
|
-
include_jarvis_config: includeJarvisConfig
|
|
334
|
-
}, Types_1.QueryIds.ADMIN_METADATA, Types_1.XWAPaths.xwa2_newsletter_admin);
|
|
335
|
-
},
|
|
336
|
-
newsletterAdminProfileUpdate: async (jid, updates) => {
|
|
337
|
-
return executeWMexQuery({ newsletter_id: jid, updates }, Types_1.QueryIds.ADMIN_PROFILE_UPDATE, Types_1.XWAPaths.xwa2_newsletter_admin_profile_update);
|
|
338
|
-
},
|
|
339
|
-
newsletterDirectoryList: async (options = {}) => {
|
|
340
|
-
const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options;
|
|
341
|
-
const variables = { limit, sort_field: sortField, sort_order: sortOrder };
|
|
342
|
-
if (interests?.length)
|
|
343
|
-
variables.interests = interests;
|
|
344
|
-
return executeWMexQuery(variables, Types_1.QueryIds.DIRECTORY_LIST, Types_1.XWAPaths.xwa2_newsletters_directory_list);
|
|
345
|
-
},
|
|
346
|
-
newsletterDirectorySearch: async (searchText, options = {}) => {
|
|
347
|
-
const { limit = 20, startCursor = null, categories = null } = options;
|
|
348
|
-
const variables = { search_text: searchText, limit };
|
|
349
|
-
if (startCursor)
|
|
350
|
-
variables.start_cursor = startCursor;
|
|
351
|
-
if (categories?.length)
|
|
352
|
-
variables.categories = categories;
|
|
353
|
-
return executeWMexQuery(variables, Types_1.QueryIds.DIRECTORY_SEARCH, Types_1.XWAPaths.xwa2_newsletters_directory_search);
|
|
354
|
-
},
|
|
355
|
-
newsletterDirectoryCategoryPreview: async (limit = 5) => {
|
|
356
|
-
return executeWMexQuery({ limit }, Types_1.QueryIds.DIRECTORY_CATEGORY_PREVIEW, Types_1.XWAPaths.xwa2_newsletters_directory_category_preview);
|
|
357
|
-
},
|
|
358
|
-
newsletterSearch: async (query, limit = 20, startCursor = null) => {
|
|
359
|
-
const variables = { query, limit };
|
|
360
|
-
if (startCursor)
|
|
361
|
-
variables.start_cursor = startCursor;
|
|
362
|
-
return executeWMexQuery(variables, Types_1.QueryIds.SEARCH, Types_1.XWAPaths.xwa2_newsletters_search);
|
|
363
|
-
},
|
|
364
|
-
newsletterRecommended: async (limit = 10, numFollowed = null) => {
|
|
365
|
-
const variables = { limit };
|
|
366
|
-
if (numFollowed != null)
|
|
367
|
-
variables.num_newsletters_followed = numFollowed;
|
|
368
|
-
return executeWMexQuery(variables, Types_1.QueryIds.RECOMMENDED, Types_1.XWAPaths.xwa2_newsletters_recommended);
|
|
369
|
-
},
|
|
370
|
-
newsletterSimilar: async (jid, limit = 10) => {
|
|
371
|
-
return executeWMexQuery({ newsletter_id: jid, limit }, Types_1.QueryIds.SIMILAR, Types_1.XWAPaths.xwa2_newsletters_similar);
|
|
372
|
-
},
|
|
373
|
-
newsletterFollowingList: async (startCursor = null, limit = 20) => {
|
|
374
|
-
const variables = { limit };
|
|
375
|
-
if (startCursor)
|
|
376
|
-
variables.start_cursor = startCursor;
|
|
377
|
-
return executeWMexQuery(variables, Types_1.QueryIds.FOLLOWING_LIST, Types_1.XWAPaths.xwa2_newsletter_following);
|
|
378
|
-
},
|
|
379
|
-
newsletterInsights: async (jid, period = null) => {
|
|
380
|
-
const variables = { newsletter_id: jid };
|
|
381
|
-
if (period)
|
|
382
|
-
variables.period = period;
|
|
383
|
-
return executeWMexQuery(variables, Types_1.QueryIds.INSIGHTS, Types_1.XWAPaths.xwa2_newsletter_admin_insights);
|
|
384
|
-
},
|
|
385
|
-
newsletterPollVoterList: async (jid, serverId, option = null, startCursor = null) => {
|
|
386
|
-
const variables = { id: jid, server_id: serverId };
|
|
387
|
-
if (option != null)
|
|
388
|
-
variables.option = option;
|
|
389
|
-
if (startCursor)
|
|
390
|
-
variables.start_cursor = startCursor;
|
|
391
|
-
return executeWMexQuery(variables, Types_1.QueryIds.POLL_VOTER_LIST, Types_1.XWAPaths.xwa2_newsletters_poll_voter_list);
|
|
392
|
-
},
|
|
393
|
-
newsletterReactionSenders: async (jid, serverId, startCursor = null) => {
|
|
394
|
-
const variables = { id: jid, server_id: serverId };
|
|
395
|
-
if (startCursor)
|
|
396
|
-
variables.start_cursor = startCursor;
|
|
397
|
-
return executeWMexQuery(variables, Types_1.QueryIds.REACTION_SENDERS_LIST, Types_1.XWAPaths.xwa2_newsletters_reaction_sender_list);
|
|
398
|
-
},
|
|
399
|
-
newsletterBlockUser: async (jid, userJid) => {
|
|
400
|
-
return executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.BLOCK_USER, 'xwa2_newsletter_block_user');
|
|
401
|
-
},
|
|
402
|
-
newsletterEnableWamo: async (jid) => {
|
|
403
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ENABLE_SUB, 'xwa2_newsletter_wamo_enable_sub');
|
|
404
|
-
},
|
|
405
|
-
newsletterDisableWamo: async (jid) => {
|
|
406
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_DISABLE_SUB, 'xwa2_newsletter_wamo_disable_sub');
|
|
407
|
-
},
|
|
408
|
-
newsletterChangeWamo: async (jid, subConfig) => {
|
|
409
|
-
return executeWMexQuery({ newsletter_id: jid, ...subConfig }, Types_1.QueryIds.WAMO_CHANGE_SUB, 'xwa2_newsletter_wamo_change_sub');
|
|
410
|
-
},
|
|
411
|
-
wamoAfsAgeCollection: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION, Types_1.XWAPaths.xwa2_wamo_afs_age_collection),
|
|
412
|
-
wamoAssetCollection: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ASSET_COLLECTION, Types_1.XWAPaths.xwa2_wamo_asset_collection),
|
|
413
|
-
wamoFetchAdhocNotice: async (noticeId) => executeWMexQuery({ notice_id: noticeId }, Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE, Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id),
|
|
414
|
-
wamoFetchIdentityToken: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN, Types_1.XWAPaths.xwa2_wamo_fetch_identity_token),
|
|
415
|
-
wamoSubComplianceInfo: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO, Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info),
|
|
416
|
-
wamoUserIdVersion: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_user_id_version),
|
|
417
|
-
wamoSetUserIdVersion: async (jid, version) => executeWMexQuery({ newsletter_id: jid, version }, Types_1.QueryIds.WAMO_SET_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_set_user_id_version),
|
|
418
|
-
newsletterLeave: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.LEAVE, Types_1.XWAPaths.xwa2_newsletter_leave_v2),
|
|
419
|
-
newsletterCreateVerified: async (name, description = null) => executeWMexQuery({ input: { name, description } }, Types_1.QueryIds.CREATE_VERIFIED, Types_1.XWAPaths.xwa2_newsletter_create_verified),
|
|
420
|
-
newsletterEnforcements: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ENFORCEMENTS, Types_1.XWAPaths.xwa2_newsletter_enforcements),
|
|
421
|
-
newsletterUserReports: async (jid, cursor = null) => {
|
|
422
|
-
const variables = { newsletter_id: jid };
|
|
423
|
-
if (cursor)
|
|
424
|
-
variables.cursor = cursor;
|
|
425
|
-
return executeWMexQuery(variables, Types_1.QueryIds.USER_REPORTS, Types_1.XWAPaths.xwa2_newsletter_user_reports);
|
|
426
|
-
},
|
|
427
|
-
newsletterCreateReportAppeal: async (jid, reason) => executeWMexQuery({ newsletter_id: jid, reason }, Types_1.QueryIds.CREATE_REPORT_APPEAL, Types_1.XWAPaths.xwa2_newsletter_create_report_appeal),
|
|
428
|
-
newsletterLinkPreviewCheck: async (url) => executeWMexQuery({ url }, Types_1.QueryIds.LINK_PREVIEW_CHECK, Types_1.XWAPaths.xwa2_newsletter_link_preview_check),
|
|
429
|
-
newsletterUpdateVerification: async (jid, verification) => executeWMexQuery({ newsletter_id: jid, verification }, Types_1.QueryIds.UPDATE_VERIFICATION, Types_1.XWAPaths.xwa2_newsletter_update_verification),
|
|
430
|
-
newsletterLabelPaidPartnership: async (jid, serverId, isPaidPartnership) => executeWMexQuery({ newsletter_id: jid, server_id: serverId, is_paid_partnership: isPaidPartnership }, Types_1.QueryIds.LABEL_PAID_PARTNERSHIP, Types_1.XWAPaths.xwa2_newsletter_label_paid_partnership),
|
|
431
|
-
newsletterLogExposures: async (events) => executeWMexQuery({ events }, Types_1.QueryIds.LOG_EXPOSURES, Types_1.XWAPaths.xwa2_newsletter_log_exposures),
|
|
432
|
-
newsletterUpdateUserSetting: async (jid, setting) => executeWMexQuery({ newsletter_id: jid, ...setting }, Types_1.QueryIds.UPDATE_USER_SETTING, Types_1.XWAPaths.xwa2_newsletter_update_user_setting),
|
|
433
|
-
newsletterRankingFeatures: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.RANKING_FEATURES, Types_1.XWAPaths.xwa2_newsletter_ranking_features),
|
|
434
|
-
newsletterSendViewReceipt: async (jid, serverMessageIds) => {
|
|
435
|
-
const ids = Array.isArray(serverMessageIds) ? serverMessageIds : [serverMessageIds];
|
|
436
|
-
const receiptId = generateMessageTag();
|
|
437
|
-
await query({
|
|
438
|
-
tag: 'receipt',
|
|
439
|
-
attrs: {
|
|
440
|
-
to: jid,
|
|
441
|
-
id: receiptId,
|
|
442
|
-
type: 'view'
|
|
443
|
-
},
|
|
444
|
-
content: [
|
|
445
|
-
{
|
|
446
|
-
tag: 'list',
|
|
447
|
-
attrs: {},
|
|
448
|
-
content: ids.map(id => ({ tag: 'item', attrs: { server_id: String(id) } }))
|
|
449
|
-
}
|
|
450
|
-
]
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
};
|
|
455
|
-
exports.makeNewsletterSocket = makeNewsletterSocket;
|
package/src/Socket/privacy.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
exports.makePrivacySocket = void 0;
|
|
4
|
-
const { executeWMexQuery } = require('./mex');
|
|
5
|
-
const PRIVACY_MEX_IDS = {
|
|
6
|
-
GET_SETTINGS: '32774292262215380',
|
|
7
|
-
SET_SETTING: '26887749497493184',
|
|
8
|
-
UPDATE_CONTACT_LIST: '26375158178762800',
|
|
9
|
-
GET_CONTACT_LIST: '25700444246275824',
|
|
10
|
-
UPDATE_TEXT_STATUS: '25863197129975892',
|
|
11
|
-
GET_TEXT_STATUS_LIST: '25741205615468936',
|
|
12
|
-
UPDATE_USER_STATUS: '7452341274886724',
|
|
13
|
-
FETCH_USER_PICTURE: '24983561624604410',
|
|
14
|
-
PROFILE_PICTURE_MUTATION: '24714239711610700',
|
|
15
|
-
ACCOUNT_LOGIN: '27298465499757130',
|
|
16
|
-
ACCOUNT_LOGOUT: '26863447609979190',
|
|
17
|
-
MULTI_ACCOUNT_REVOKE: '25846242091639660',
|
|
18
|
-
ADD_MULTI_ACCOUNT_LINK: '25502812266025190',
|
|
19
|
-
ADD_TRUSTED_DEVICE: '24522952587403290',
|
|
20
|
-
GET_TRUSTED_DEVICES: '25123358920671964',
|
|
21
|
-
UNTRUST_TRUSTED_DEVICE: '26574930682133620',
|
|
22
|
-
DELETE_TRUSTED_DEVICE: '33867503889559536',
|
|
23
|
-
MOBILE_CONFIG_FETCH: '25676911271914596',
|
|
24
|
-
NOTIFY_PUSH_NAME: '25900490552974544',
|
|
25
|
-
CONTACT_INTEGRITY: '25924358997169496',
|
|
26
|
-
BIZ_INTEGRITY: '25975613018777536',
|
|
27
|
-
LINKED_PROFILES_SET: '25013968611531010',
|
|
28
|
-
LINKED_PROFILES_REMOVE: '24537675509265524',
|
|
29
|
-
LINKED_PROFILES_UPDATE: '24876967165297616',
|
|
30
|
-
MIGRATE_BLOCKLIST_LID: '25028600226770430',
|
|
31
|
-
QR_CODE_SCAN: '26287165600869744'
|
|
32
|
-
};
|
|
33
|
-
const makePrivacySocket = sock => {
|
|
34
|
-
const { query, generateMessageTag } = sock;
|
|
35
|
-
const mexQuery = (variables, queryId, dataPath) => executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag);
|
|
36
|
-
const getPrivacySettings = (jid, features = null) => {
|
|
37
|
-
const users = [{ jid, ...(features ? { privacy_features: features } : {}) }];
|
|
38
|
-
return mexQuery({ users }, PRIVACY_MEX_IDS.GET_SETTINGS, 'xwa2_fetch_wa_users');
|
|
39
|
-
};
|
|
40
|
-
const setPrivacySetting = (feature, setting) => mexQuery({ feature, setting }, PRIVACY_MEX_IDS.SET_SETTING, 'xwa2_privacy_feature_update');
|
|
41
|
-
const updatePrivacyContactList = (feature, setting, jids) => mexQuery({ feature, setting, contacts: jids.map(jid => ({ jid })) }, PRIVACY_MEX_IDS.UPDATE_CONTACT_LIST, 'xwa2_privacy_contact_list_update');
|
|
42
|
-
const getPrivacyContactList = (feature, setting) => mexQuery({ feature, setting }, PRIVACY_MEX_IDS.GET_CONTACT_LIST, 'xwa2_privacy_contact_list');
|
|
43
|
-
const updateTextStatus = (text, emoji = null) => {
|
|
44
|
-
const input = { text };
|
|
45
|
-
if (emoji)
|
|
46
|
-
input.emoji = { content: emoji };
|
|
47
|
-
return mexQuery({ text_status_input: input }, PRIVACY_MEX_IDS.UPDATE_TEXT_STATUS, 'xwa2_text_status_update');
|
|
48
|
-
};
|
|
49
|
-
const getTextStatusList = (jids, lastUpdateTime = null) => {
|
|
50
|
-
const input = jids.map(jid => ({ jid, last_update_time: lastUpdateTime }));
|
|
51
|
-
return mexQuery({ input }, PRIVACY_MEX_IDS.GET_TEXT_STATUS_LIST, 'xwa2_text_status_list');
|
|
52
|
-
};
|
|
53
|
-
const updateUserStatus = status => mexQuery({ status }, PRIVACY_MEX_IDS.UPDATE_USER_STATUS, 'xwa2_update_user_status');
|
|
54
|
-
const fetchUserPictureInfo = jid => mexQuery({ jid }, PRIVACY_MEX_IDS.FETCH_USER_PICTURE, 'xwa2_fetch_user_picture_info');
|
|
55
|
-
const setProfilePictureMex = (imageBase64, type = 'image') => mexQuery({ input: { image: imageBase64, type } }, PRIVACY_MEX_IDS.PROFILE_PICTURE_MUTATION, 'xwa2_profile_picture_mutation');
|
|
56
|
-
const accountLogin = phoneNumber => mexQuery({ input: { phone_number: phoneNumber } }, PRIVACY_MEX_IDS.ACCOUNT_LOGIN, 'xwa2_account_login');
|
|
57
|
-
const accountLogout = (phoneNumber, enabledBiometric = false) => mexQuery({ input: { phone_number: phoneNumber, enabled_biometric: enabledBiometric } }, PRIVACY_MEX_IDS.ACCOUNT_LOGOUT, 'xwa2_account_logout');
|
|
58
|
-
const addMultiAccountLink = phoneNumber => mexQuery({ input: { phone_number: phoneNumber } }, PRIVACY_MEX_IDS.ADD_MULTI_ACCOUNT_LINK, 'xwa2_add_multi_account_link');
|
|
59
|
-
const addTrustedDevice = (deviceId, deviceName) => mexQuery({ device_id: deviceId, device_name: deviceName }, PRIVACY_MEX_IDS.ADD_TRUSTED_DEVICE, 'xwa2_add_trusted_device');
|
|
60
|
-
const getTrustedDevices = () => mexQuery({}, PRIVACY_MEX_IDS.GET_TRUSTED_DEVICES, 'xwa2_get_trusted_devices');
|
|
61
|
-
const untrustTrustedDevice = (deviceId, reason = 'USER_INITIATED') => mexQuery({ device_id: deviceId, reason }, PRIVACY_MEX_IDS.UNTRUST_TRUSTED_DEVICE, 'xwa2_untrust_trusted_device');
|
|
62
|
-
const deleteTrustedDevice = deviceId => mexQuery({ device_id: deviceId }, PRIVACY_MEX_IDS.DELETE_TRUSTED_DEVICE, 'xwa2_delete_trusted_device');
|
|
63
|
-
const revokeMultiAccount = accountJid => mexQuery({ account_jid: accountJid }, PRIVACY_MEX_IDS.MULTI_ACCOUNT_REVOKE, 'xwa2_multi_account_revoke');
|
|
64
|
-
const fetchMobileConfig = (apiVersion = 0, epRefreshId = 0, flags = '') => mexQuery({ api_version: apiVersion, ep_refresh_id: epRefreshId, flags }, PRIVACY_MEX_IDS.MOBILE_CONFIG_FETCH, 'xwa2_mobile_config_fetch');
|
|
65
|
-
const notifyPushName = (groupJid, participants) => mexQuery({
|
|
66
|
-
input: {
|
|
67
|
-
group_jid: groupJid,
|
|
68
|
-
participants: participants.map(({ jid, pushName }) => ({ jid, push_name: pushName }))
|
|
69
|
-
}
|
|
70
|
-
}, PRIVACY_MEX_IDS.NOTIFY_PUSH_NAME, 'xwa2_notify_push_name');
|
|
71
|
-
const contactIntegrityQuery = (jids, useCase = 'START_CHAT_CONTEXT') => mexQuery({ users: jids.map(jid => ({ jid })), use_case: useCase }, PRIVACY_MEX_IDS.CONTACT_INTEGRITY, 'xwa2_fetch_wa_users');
|
|
72
|
-
const bizIntegrityQuery = jids => mexQuery({ users: jids.map(jid => ({ jid })) }, PRIVACY_MEX_IDS.BIZ_INTEGRITY, 'xwa2_fetch_wa_users');
|
|
73
|
-
const linkedProfilesSet = profiles => {
|
|
74
|
-
const mapped = profiles.map(p => {
|
|
75
|
-
const entry = { type: p.type };
|
|
76
|
-
if (p.vid)
|
|
77
|
-
entry.vid = p.vid;
|
|
78
|
-
else if (p.username)
|
|
79
|
-
entry.username = p.username;
|
|
80
|
-
return entry;
|
|
81
|
-
});
|
|
82
|
-
return mexQuery({ profiles: mapped }, PRIVACY_MEX_IDS.LINKED_PROFILES_SET, 'xwa2_linked_profiles_set');
|
|
83
|
-
};
|
|
84
|
-
const linkedProfilesRemove = types => mexQuery({ profiles: types.map(type => ({ type })) }, PRIVACY_MEX_IDS.LINKED_PROFILES_REMOVE, 'xwa2_linked_profiles_remove');
|
|
85
|
-
const linkedProfilesUpdate = profiles => mexQuery({ profiles: profiles.map(({ type, showOnProfile }) => ({ type, show_on_profile: showOnProfile })) }, PRIVACY_MEX_IDS.LINKED_PROFILES_UPDATE, 'xwa2_linked_profiles_update');
|
|
86
|
-
const migrateBlocklistLid = (jids, dhash = '', dirtyAck = true) => mexQuery({
|
|
87
|
-
input: {
|
|
88
|
-
blocklist: jids.map(jid => ({ jid })),
|
|
89
|
-
dhash,
|
|
90
|
-
dirty_ack: dirtyAck
|
|
91
|
-
}
|
|
92
|
-
}, PRIVACY_MEX_IDS.MIGRATE_BLOCKLIST_LID, 'xwa2_migrate_blocklist_lid');
|
|
93
|
-
const qrCodeScan = qrData => mexQuery({ qr_data: qrData }, PRIVACY_MEX_IDS.QR_CODE_SCAN, 'xwa2_qr_code_scan');
|
|
94
|
-
return {
|
|
95
|
-
...sock,
|
|
96
|
-
getPrivacySettings,
|
|
97
|
-
setPrivacySetting,
|
|
98
|
-
updatePrivacyContactList,
|
|
99
|
-
getPrivacyContactList,
|
|
100
|
-
updateTextStatus,
|
|
101
|
-
getTextStatusList,
|
|
102
|
-
updateUserStatus,
|
|
103
|
-
fetchUserPictureInfo,
|
|
104
|
-
setProfilePictureMex,
|
|
105
|
-
accountLogin,
|
|
106
|
-
accountLogout,
|
|
107
|
-
addMultiAccountLink,
|
|
108
|
-
addTrustedDevice,
|
|
109
|
-
getTrustedDevices,
|
|
110
|
-
untrustTrustedDevice,
|
|
111
|
-
deleteTrustedDevice,
|
|
112
|
-
revokeMultiAccount,
|
|
113
|
-
fetchMobileConfig,
|
|
114
|
-
notifyPushName,
|
|
115
|
-
contactIntegrityQuery,
|
|
116
|
-
bizIntegrityQuery,
|
|
117
|
-
linkedProfilesSet,
|
|
118
|
-
linkedProfilesRemove,
|
|
119
|
-
linkedProfilesUpdate,
|
|
120
|
-
migrateBlocklistLid,
|
|
121
|
-
qrCodeScan,
|
|
122
|
-
PRIVACY_MEX_IDS
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
exports.makePrivacySocket = makePrivacySocket;
|