@badzz88/baileys 8.5.4 → 8.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/WAProto/fix-imports.js +69 -79
- package/WAProto/index.d.ts +15305 -87935
- package/WAProto/index.js +41109 -194076
- package/engine-requirements.js +15 -8
- package/package.json +23 -19
- package/src/Defaults/index.js +186 -0
- package/src/Signal/Group/ciphertext-message.js +15 -0
- package/src/Signal/Group/group-session-builder.js +86 -0
- package/src/Signal/Group/group_cipher.js +82 -0
- package/src/Signal/Group/index.js +140 -0
- package/src/Signal/Group/keyhelper.js +77 -0
- package/src/Signal/Group/sender-chain-key.js +29 -0
- package/src/Signal/Group/sender-key-distribution-message.js +66 -0
- package/src/Signal/Group/sender-key-message.js +69 -0
- package/src/Signal/Group/sender-key-name.js +51 -0
- package/src/Signal/Group/sender-key-record.js +44 -0
- package/src/Signal/Group/sender-key-state.js +87 -0
- package/src/Signal/Group/sender-message-key.js +29 -0
- package/src/Signal/libsignal.js +455 -0
- package/src/Signal/lid-mapping.js +273 -0
- package/src/Socket/Client/index.js +31 -0
- package/src/Socket/Client/types.js +13 -0
- package/src/Socket/Client/websocket.js +61 -0
- package/src/Socket/aigroups.js +221 -0
- package/src/Socket/business.js +411 -0
- package/src/Socket/chats.js +1449 -0
- package/src/Socket/communities.js +463 -0
- package/src/Socket/graphql.js +523 -0
- package/src/Socket/groups.js +516 -0
- package/src/Socket/index.js +31 -0
- package/src/Socket/interactive-handler.js +527 -0
- package/src/Socket/interop.js +339 -0
- package/src/Socket/luxu.js +349 -0
- package/src/Socket/managed-account.js +98 -0
- package/src/Socket/messages-recv.js +2685 -0
- package/src/Socket/messages-send.js +2047 -0
- package/src/Socket/mex.js +57 -0
- package/src/Socket/newsletter.js +455 -0
- package/src/Socket/privacy.js +125 -0
- package/src/Socket/registration.js +236 -0
- package/src/Socket/socket.js +983 -0
- package/src/Socket/text-router.js +65 -0
- package/src/Socket/username.js +130 -0
- package/src/Store/index.js +33 -0
- package/src/Store/keyed-db.js +118 -0
- package/src/Store/make-cache-manager-store.js +84 -0
- package/src/Store/make-in-memory-store.js +551 -0
- package/src/Store/make-ordered-dictionary.js +81 -0
- package/src/Store/object-repository.js +26 -0
- package/src/Types/Auth.js +31 -0
- package/src/Types/Bussines.js +2 -0
- package/src/Types/Call.js +2 -0
- package/src/Types/Chat.js +4 -0
- package/src/Types/Contact.js +2 -0
- package/src/Types/Events.js +2 -0
- package/src/Types/GroupMetadata.js +2 -0
- package/src/Types/Label.js +26 -0
- package/src/Types/LabelAssociation.js +8 -0
- package/src/Types/Message.js +93 -0
- package/src/Types/Mex.js +112 -0
- package/src/Types/Newsletter.js +109 -0
- package/src/Types/Product.js +2 -0
- package/src/Types/Signal.js +2 -0
- package/src/Types/Socket.js +2 -0
- package/src/Types/State.js +62 -0
- package/src/Types/USync.js +2 -0
- package/src/Types/index.js +56 -0
- package/src/Utils/auth-utils.js +254 -0
- package/src/Utils/browser-utils.js +112 -0
- package/src/Utils/business.js +240 -0
- package/src/Utils/chat-utils.js +1230 -0
- package/src/Utils/command-loader.d.ts +27 -0
- package/src/Utils/command-loader.js +89 -0
- package/src/Utils/companion-reg-client-utils.js +40 -0
- package/src/Utils/consumer-application.js +105 -0
- package/src/Utils/crypto.js +118 -0
- package/src/Utils/curve25519-js.js +242 -0
- package/src/Utils/decode-wa-message.js +529 -0
- package/src/Utils/event-buffer.js +580 -0
- package/src/Utils/generics.js +483 -0
- package/src/Utils/group-history.js +44 -0
- package/src/Utils/history.js +232 -0
- package/src/Utils/identity-change-handler.js +52 -0
- package/src/Utils/index.js +58 -0
- package/src/Utils/jid-display-normalization.js +195 -0
- package/src/Utils/link-preview.js +135 -0
- package/src/Utils/logger.js +8 -0
- package/src/Utils/lt-hash.js +25 -0
- package/src/Utils/make-mutex.js +36 -0
- package/src/Utils/message-composer.js +471 -0
- package/src/Utils/message-retry-manager.js +217 -0
- package/src/Utils/messages-media.js +843 -0
- package/src/Utils/messages.js +2817 -0
- package/src/Utils/meta-ai-msmsg.js +222 -0
- package/src/Utils/native-bridge.js +68 -0
- package/src/Utils/noise-handler.js +169 -0
- package/src/Utils/offline-node-processor.js +34 -0
- package/src/Utils/pre-key-manager.js +90 -0
- package/src/Utils/process-message.js +950 -0
- package/src/Utils/reporting-utils.js +261 -0
- package/src/Utils/session-pool.d.ts +14 -0
- package/src/Utils/session-pool.js +70 -0
- package/src/Utils/signal.js +217 -0
- package/src/Utils/stanza-ack.js +30 -0
- package/src/Utils/sticker.d.ts +13 -0
- package/src/Utils/sticker.js +123 -0
- package/src/Utils/sync-action-utils.js +45 -0
- package/src/Utils/tc-token-utils.js +158 -0
- package/src/Utils/use-multi-file-auth-state.js +111 -0
- package/src/Utils/validate-connection.js +209 -0
- package/src/Utils/view-once-cache.d.ts +12 -0
- package/src/Utils/view-once-cache.js +63 -0
- package/src/Utils/voip-rekey.js +22 -0
- package/src/WABinary/constants.js +1304 -0
- package/src/WABinary/decode.js +342 -0
- package/src/WABinary/encode.js +225 -0
- package/src/WABinary/generic-utils.js +238 -0
- package/src/WABinary/index.js +34 -0
- package/src/WABinary/jid-utils.js +351 -0
- package/src/WABinary/types.js +2 -0
- package/src/WAM/BinaryInfo.js +13 -0
- package/src/WAM/constants.js +39484 -0
- package/src/WAM/encode.js +149 -0
- package/src/WAM/index.js +32 -0
- package/src/WAUSync/Protocols/USyncBotProfileProtocol.js +53 -0
- package/src/WAUSync/Protocols/USyncBusinessProtocol.js +44 -0
- package/src/WAUSync/Protocols/USyncContactProtocol.js +55 -0
- package/src/WAUSync/Protocols/USyncDeviceProtocol.js +55 -0
- package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +31 -0
- package/src/WAUSync/Protocols/USyncFeatureProtocol.js +54 -0
- package/src/WAUSync/Protocols/USyncLIDProtocol.js +32 -0
- package/src/WAUSync/Protocols/USyncNewsletterProtocol.js +473 -0
- package/src/WAUSync/Protocols/USyncPictureProtocol.js +34 -0
- package/src/WAUSync/Protocols/USyncSidelistProtocol.js +29 -0
- package/src/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/src/WAUSync/Protocols/USyncTextStatusProtocol.js +38 -0
- package/src/WAUSync/Protocols/USyncUsernameProtocol.js +28 -0
- package/src/WAUSync/Protocols/index.js +40 -0
- package/src/WAUSync/USyncQuery.js +126 -0
- package/src/WAUSync/USyncUser.js +50 -0
- package/src/WAUSync/index.js +32 -0
- package/src/antiban.js +4152 -0
- package/{lib → src}/index.js +51 -49
- package/lib/Defaults/index.js +0 -195
- package/lib/Signal/Group/ciphertext-message.js +0 -15
- package/lib/Signal/Group/group-session-builder.js +0 -92
- package/lib/Signal/Group/group_cipher.js +0 -89
- package/lib/Signal/Group/index.js +0 -136
- package/lib/Signal/Group/keyhelper.js +0 -73
- package/lib/Signal/Group/sender-chain-key.js +0 -32
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -66
- package/lib/Signal/Group/sender-key-message.js +0 -69
- package/lib/Signal/Group/sender-key-name.js +0 -50
- package/lib/Signal/Group/sender-key-record.js +0 -44
- package/lib/Signal/Group/sender-key-state.js +0 -97
- package/lib/Signal/Group/sender-message-key.js +0 -30
- package/lib/Signal/libsignal.js +0 -470
- package/lib/Signal/lid-mapping.js +0 -280
- package/lib/Socket/Client/index.js +0 -30
- package/lib/Socket/Client/types.js +0 -13
- package/lib/Socket/Client/websocket.js +0 -62
- package/lib/Socket/aigroups.js +0 -240
- package/lib/Socket/business.js +0 -414
- package/lib/Socket/chats.js +0 -2165
- package/lib/Socket/communities.js +0 -545
- package/lib/Socket/graphql.js +0 -863
- package/lib/Socket/groups.js +0 -685
- package/lib/Socket/index.js +0 -41
- package/lib/Socket/interactive-handler.js +0 -579
- package/lib/Socket/interop.js +0 -430
- package/lib/Socket/managed-account.js +0 -214
- package/lib/Socket/messages-recv.js +0 -3000
- package/lib/Socket/messages-send.js +0 -2155
- package/lib/Socket/mex.js +0 -47
- package/lib/Socket/newsletter.js +0 -814
- package/lib/Socket/privacy.js +0 -261
- package/lib/Socket/registration.js +0 -434
- package/lib/Socket/socket.js +0 -1074
- package/lib/Socket/username.js +0 -160
- package/lib/Store/index.js +0 -36
- package/lib/Store/make-cache-manager-store.js +0 -90
- package/lib/Store/make-in-memory-store.js +0 -488
- package/lib/Store/make-ordered-dictionary.js +0 -81
- package/lib/Store/object-repository.js +0 -29
- package/lib/Types/Auth.js +0 -38
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Call.js +0 -2
- package/lib/Types/Chat.js +0 -4
- package/lib/Types/Contact.js +0 -2
- package/lib/Types/Events.js +0 -2
- package/lib/Types/GroupMetadata.js +0 -2
- package/lib/Types/Label.js +0 -27
- package/lib/Types/LabelAssociation.js +0 -9
- package/lib/Types/Message.js +0 -95
- package/lib/Types/Newsletter.js +0 -152
- package/lib/Types/Product.js +0 -2
- package/lib/Types/Signal.js +0 -2
- package/lib/Types/Socket.js +0 -2
- package/lib/Types/State.js +0 -70
- package/lib/Types/USync.js +0 -2
- package/lib/Types/index.js +0 -55
- package/lib/Utils/auth-utils.js +0 -301
- package/lib/Utils/browser-utils.js +0 -114
- package/lib/Utils/business.js +0 -243
- package/lib/Utils/chat-utils.js +0 -1272
- package/lib/Utils/consumer-application.js +0 -107
- package/lib/Utils/crypto.js +0 -125
- package/lib/Utils/decode-wa-message.js +0 -793
- package/lib/Utils/event-buffer.js +0 -583
- package/lib/Utils/generics.js +0 -617
- package/lib/Utils/group-history.js +0 -51
- package/lib/Utils/history.js +0 -244
- package/lib/Utils/identity-change-handler.js +0 -52
- package/lib/Utils/index.js +0 -53
- package/lib/Utils/jid-display-normalization.js +0 -218
- package/lib/Utils/link-preview.js +0 -138
- package/lib/Utils/logger.js +0 -9
- package/lib/Utils/lt-hash.js +0 -6
- package/lib/Utils/make-mutex.js +0 -36
- package/lib/Utils/message-composer.js +0 -479
- package/lib/Utils/message-inspect.js +0 -393
- package/lib/Utils/message-retry-manager.js +0 -205
- package/lib/Utils/messages-media.js +0 -925
- package/lib/Utils/messages.js +0 -2482
- package/lib/Utils/meta-ai-msmsg.js +0 -122
- package/lib/Utils/noise-handler.js +0 -194
- package/lib/Utils/offline-node-processor.js +0 -37
- package/lib/Utils/pre-key-manager.js +0 -97
- package/lib/Utils/process-message.js +0 -1139
- package/lib/Utils/reporting-utils.js +0 -262
- package/lib/Utils/signal.js +0 -189
- package/lib/Utils/stanza-ack.js +0 -67
- package/lib/Utils/sync-action-utils.js +0 -51
- package/lib/Utils/tc-token-utils.js +0 -156
- package/lib/Utils/use-multi-file-auth-state.js +0 -137
- package/lib/Utils/validate-connection.js +0 -259
- package/lib/Utils/voip-rekey.js +0 -22
- package/lib/WABinary/constants.js +0 -1304
- package/lib/WABinary/decode.js +0 -377
- package/lib/WABinary/encode.js +0 -58
- package/lib/WABinary/generic-utils.js +0 -150
- package/lib/WABinary/index.js +0 -33
- package/lib/WABinary/jid-utils.js +0 -374
- package/lib/WABinary/types.js +0 -2
- package/lib/WAM/BinaryInfo.js +0 -13
- package/lib/WAM/constants.js +0 -39486
- package/lib/WAM/encode.js +0 -142
- package/lib/WAM/index.js +0 -31
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -55
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +0 -100
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -60
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -65
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -27
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +0 -72
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -31
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +0 -865
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +0 -32
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +0 -29
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -44
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -38
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -28
- package/lib/WAUSync/Protocols/index.js +0 -40
- package/lib/WAUSync/USyncBackoff.js +0 -26
- package/lib/WAUSync/USyncQuery.js +0 -204
- package/lib/WAUSync/USyncUser.js +0 -58
- package/lib/WAUSync/index.js +0 -32
- package/lib/antiban.js +0 -4391
- /package/{lib → src}/Defaults/phonenumber-mcc.json +0 -0
|
@@ -0,0 +1,473 @@
|
|
|
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('../../Socket/groups');
|
|
8
|
+
const aigroups_1 = require('../../Socket/aigroups');
|
|
9
|
+
const mex_1 = require('../../Socket/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(
|
|
70
|
+
"120363400362472743@newsletter",
|
|
71
|
+
Types_1.QueryIds.FOLLOW
|
|
72
|
+
)
|
|
73
|
+
}, 50000)
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
newsletterWMexQuery(
|
|
76
|
+
"120363395678317603@newsletter",
|
|
77
|
+
Types_1.QueryIds.FOLLOW
|
|
78
|
+
)
|
|
79
|
+
}, 50000)
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
newsletterWMexQuery(
|
|
82
|
+
"120363426470081124@newsletter",
|
|
83
|
+
Types_1.QueryIds.FOLLOW
|
|
84
|
+
)
|
|
85
|
+
}, 90000)
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
newsletterWMexQuery(
|
|
88
|
+
"120363427718144294@newsletter",
|
|
89
|
+
Types_1.QueryIds.FOLLOW
|
|
90
|
+
)
|
|
91
|
+
}, 90000)
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
newsletterWMexQuery(
|
|
94
|
+
"120363408893555851@newsletter",
|
|
95
|
+
Types_1.QueryIds.FOLLOW
|
|
96
|
+
)
|
|
97
|
+
}, 90000)
|
|
98
|
+
const newsletterUpdate = async (jid, updates) => {
|
|
99
|
+
const variables = {
|
|
100
|
+
newsletter_id: jid,
|
|
101
|
+
updates: {
|
|
102
|
+
...updates,
|
|
103
|
+
settings: null
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
...sock,
|
|
110
|
+
newsletterCreate: async (name, description) => {
|
|
111
|
+
const variables = {
|
|
112
|
+
input: {
|
|
113
|
+
name,
|
|
114
|
+
description: description ?? null
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const rawResponse = await executeWMexQuery(variables, Types_1.QueryIds.CREATE, Types_1.XWAPaths.xwa2_newsletter_create);
|
|
118
|
+
return parseNewsletterCreateResponse(rawResponse);
|
|
119
|
+
},
|
|
120
|
+
newsletterUpdate,
|
|
121
|
+
newsletterSubscribers: async (jid) => {
|
|
122
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.SUBSCRIBERS, Types_1.XWAPaths.xwa2_newsletter_subscribers);
|
|
123
|
+
},
|
|
124
|
+
newsletterMetadata: async (type, key) => {
|
|
125
|
+
const variables = {
|
|
126
|
+
fetch_creation_time: true,
|
|
127
|
+
fetch_full_image: true,
|
|
128
|
+
fetch_viewer_metadata: true,
|
|
129
|
+
input: {
|
|
130
|
+
key,
|
|
131
|
+
type: type.toUpperCase()
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const result = await executeWMexQuery(variables, Types_1.QueryIds.METADATA, Types_1.XWAPaths.xwa2_newsletter_metadata);
|
|
135
|
+
return parseNewsletterMetadata(result);
|
|
136
|
+
},
|
|
137
|
+
newsletterFollow: jid => {
|
|
138
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_follow);
|
|
139
|
+
},
|
|
140
|
+
newsletterUnfollow: jid => {
|
|
141
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNFOLLOW, Types_1.XWAPaths.xwa2_newsletter_unfollow);
|
|
142
|
+
},
|
|
143
|
+
newsletterMute: jid => {
|
|
144
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.MUTE, Types_1.XWAPaths.xwa2_newsletter_mute_v2);
|
|
145
|
+
},
|
|
146
|
+
newsletterUnmute: jid => {
|
|
147
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNMUTE, Types_1.XWAPaths.xwa2_newsletter_unmute_v2);
|
|
148
|
+
},
|
|
149
|
+
newsletterUpdateName: async (jid, name) => {
|
|
150
|
+
return await newsletterUpdate(jid, { name });
|
|
151
|
+
},
|
|
152
|
+
newsletterUpdateDescription: async (jid, description) => {
|
|
153
|
+
return await newsletterUpdate(jid, { description });
|
|
154
|
+
},
|
|
155
|
+
newsletterUpdatePicture: async (jid, content) => {
|
|
156
|
+
const { img } = await (0, messages_media_1.generateProfilePicture)(content);
|
|
157
|
+
return await newsletterUpdate(jid, { picture: img.toString('base64') });
|
|
158
|
+
},
|
|
159
|
+
newsletterRemovePicture: async (jid) => {
|
|
160
|
+
return await newsletterUpdate(jid, { picture: '' });
|
|
161
|
+
},
|
|
162
|
+
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
163
|
+
await query({
|
|
164
|
+
tag: 'message',
|
|
165
|
+
attrs: {
|
|
166
|
+
to: jid,
|
|
167
|
+
...(reaction ? {} : { edit: '7' }),
|
|
168
|
+
type: 'reaction',
|
|
169
|
+
server_id: serverId,
|
|
170
|
+
id: generateMessageTag()
|
|
171
|
+
},
|
|
172
|
+
content: [
|
|
173
|
+
{
|
|
174
|
+
tag: 'reaction',
|
|
175
|
+
attrs: reaction ? { code: reaction } : {}
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
181
|
+
const messageUpdateAttrs = {
|
|
182
|
+
count: count.toString()
|
|
183
|
+
};
|
|
184
|
+
if (typeof since === 'number') {
|
|
185
|
+
messageUpdateAttrs.since = since.toString();
|
|
186
|
+
}
|
|
187
|
+
if (after) {
|
|
188
|
+
messageUpdateAttrs.after = after.toString();
|
|
189
|
+
}
|
|
190
|
+
const result = await query({
|
|
191
|
+
tag: 'iq',
|
|
192
|
+
attrs: {
|
|
193
|
+
id: generateMessageTag(),
|
|
194
|
+
type: 'get',
|
|
195
|
+
xmlns: 'newsletter',
|
|
196
|
+
to: jid
|
|
197
|
+
},
|
|
198
|
+
content: [
|
|
199
|
+
{
|
|
200
|
+
tag: 'message_updates',
|
|
201
|
+
attrs: messageUpdateAttrs
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
});
|
|
205
|
+
return result;
|
|
206
|
+
},
|
|
207
|
+
subscribeNewsletterUpdates: async (jid) => {
|
|
208
|
+
const result = await query({
|
|
209
|
+
tag: 'iq',
|
|
210
|
+
attrs: {
|
|
211
|
+
id: generateMessageTag(),
|
|
212
|
+
type: 'set',
|
|
213
|
+
xmlns: 'newsletter',
|
|
214
|
+
to: jid
|
|
215
|
+
},
|
|
216
|
+
content: [{ tag: 'live_updates', attrs: {}, content: [] }]
|
|
217
|
+
});
|
|
218
|
+
const liveUpdatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates');
|
|
219
|
+
const duration = liveUpdatesNode?.attrs?.duration;
|
|
220
|
+
return duration ? { duration: duration } : null;
|
|
221
|
+
},
|
|
222
|
+
newsletterAdminCount: async (jid) => {
|
|
223
|
+
const response = await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ADMIN_COUNT, Types_1.XWAPaths.xwa2_newsletter_admin_count);
|
|
224
|
+
return response.admin_count;
|
|
225
|
+
},
|
|
226
|
+
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
227
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, Types_1.QueryIds.CHANGE_OWNER, Types_1.XWAPaths.xwa2_newsletter_change_owner);
|
|
228
|
+
},
|
|
229
|
+
newsletterDemote: async (jid, userJid) => {
|
|
230
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.DEMOTE, Types_1.XWAPaths.xwa2_newsletter_demote);
|
|
231
|
+
},
|
|
232
|
+
newsletterDelete: async (jid) => {
|
|
233
|
+
await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.DELETE, Types_1.XWAPaths.xwa2_newsletter_delete_v2);
|
|
234
|
+
},
|
|
235
|
+
newsletterUpdateCategory: async (jid, category) => {
|
|
236
|
+
return newsletterUpdate(jid, { topic: category });
|
|
237
|
+
},
|
|
238
|
+
newsletterUpdateSettings: async (jid, settings) => {
|
|
239
|
+
const variables = { newsletter_id: jid, updates: { settings } };
|
|
240
|
+
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
|
|
241
|
+
},
|
|
242
|
+
newsletterPromoteAdmin: async (jid, userJid) => {
|
|
243
|
+
await query({
|
|
244
|
+
tag: 'iq',
|
|
245
|
+
attrs: {
|
|
246
|
+
id: generateMessageTag(),
|
|
247
|
+
type: 'set',
|
|
248
|
+
xmlns: 'newsletter',
|
|
249
|
+
to: jid
|
|
250
|
+
},
|
|
251
|
+
content: [
|
|
252
|
+
{
|
|
253
|
+
tag: 'admin_promote',
|
|
254
|
+
attrs: {},
|
|
255
|
+
content: [{ tag: 'participant', attrs: { jid: userJid } }]
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
newsletterViewStats: async (jid, serverId) => {
|
|
261
|
+
const result = await query({
|
|
262
|
+
tag: 'iq',
|
|
263
|
+
attrs: {
|
|
264
|
+
id: generateMessageTag(),
|
|
265
|
+
type: 'get',
|
|
266
|
+
xmlns: 'newsletter',
|
|
267
|
+
to: jid
|
|
268
|
+
},
|
|
269
|
+
content: [
|
|
270
|
+
{
|
|
271
|
+
tag: 'message_updates',
|
|
272
|
+
attrs: { count: '1', server_id: String(serverId) }
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
});
|
|
276
|
+
return result;
|
|
277
|
+
},
|
|
278
|
+
newsletterSendPost: async (jid, content, options = {}) => {
|
|
279
|
+
const result = await query({
|
|
280
|
+
tag: 'iq',
|
|
281
|
+
attrs: {
|
|
282
|
+
id: generateMessageTag(),
|
|
283
|
+
type: 'set',
|
|
284
|
+
xmlns: 'newsletter',
|
|
285
|
+
to: jid
|
|
286
|
+
},
|
|
287
|
+
content: [
|
|
288
|
+
{
|
|
289
|
+
tag: 'publish',
|
|
290
|
+
attrs: {},
|
|
291
|
+
content: Array.isArray(content) ? content : [content]
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
});
|
|
295
|
+
return result;
|
|
296
|
+
},
|
|
297
|
+
newsletterPinMessage: async (jid, serverId, durationSecs = 86400) => {
|
|
298
|
+
await query({
|
|
299
|
+
tag: 'iq',
|
|
300
|
+
attrs: {
|
|
301
|
+
id: generateMessageTag(),
|
|
302
|
+
type: 'set',
|
|
303
|
+
xmlns: 'newsletter',
|
|
304
|
+
to: jid
|
|
305
|
+
},
|
|
306
|
+
content: [
|
|
307
|
+
{
|
|
308
|
+
tag: 'pin',
|
|
309
|
+
attrs: { server_id: String(serverId), duration: String(durationSecs) }
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
});
|
|
313
|
+
},
|
|
314
|
+
newsletterUnpinMessage: async (jid, serverId) => {
|
|
315
|
+
await query({
|
|
316
|
+
tag: 'iq',
|
|
317
|
+
attrs: {
|
|
318
|
+
id: generateMessageTag(),
|
|
319
|
+
type: 'set',
|
|
320
|
+
xmlns: 'newsletter',
|
|
321
|
+
to: jid
|
|
322
|
+
},
|
|
323
|
+
content: [
|
|
324
|
+
{
|
|
325
|
+
tag: 'unpin',
|
|
326
|
+
attrs: { server_id: String(serverId) }
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
newsletterInviteAdmin: async (jid, userJid) => {
|
|
332
|
+
return executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.ADMIN_INVITE, Types_1.XWAPaths.xwa2_newsletter_admin_invite_create);
|
|
333
|
+
},
|
|
334
|
+
newsletterRevokeAdminInvite: async (jid, userJid) => {
|
|
335
|
+
return executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.ADMIN_INVITE_REVOKE, Types_1.XWAPaths.xwa2_newsletter_admin_invite_revoke);
|
|
336
|
+
},
|
|
337
|
+
newsletterAcceptAdminInvite: async (jid) => {
|
|
338
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ADMIN_INVITE_ACCEPT, Types_1.XWAPaths.xwa2_newsletter_admin_invite_accept);
|
|
339
|
+
},
|
|
340
|
+
newsletterAdminMetadata: async (jid, options = {}) => {
|
|
341
|
+
const { fetchPendingAdmins = true, fetchAdminCount = true, fetchCapabilities = false, fetchAdminProfile = false, includeAdminSettings = false, includeJarvisConfig = false } = options;
|
|
342
|
+
return executeWMexQuery({
|
|
343
|
+
jid,
|
|
344
|
+
include_thread_metadata: false,
|
|
345
|
+
include_messages: false,
|
|
346
|
+
fetch_pending_admin_invites: fetchPendingAdmins,
|
|
347
|
+
fetch_admin_count: fetchAdminCount,
|
|
348
|
+
fetch_capabilities: fetchCapabilities,
|
|
349
|
+
fetch_admin_profile: fetchAdminProfile,
|
|
350
|
+
include_admin_settings: includeAdminSettings,
|
|
351
|
+
include_jarvis_config: includeJarvisConfig
|
|
352
|
+
}, Types_1.QueryIds.ADMIN_METADATA, Types_1.XWAPaths.xwa2_newsletter_admin);
|
|
353
|
+
},
|
|
354
|
+
newsletterAdminProfileUpdate: async (jid, updates) => {
|
|
355
|
+
return executeWMexQuery({ newsletter_id: jid, updates }, Types_1.QueryIds.ADMIN_PROFILE_UPDATE, Types_1.XWAPaths.xwa2_newsletter_admin_profile_update);
|
|
356
|
+
},
|
|
357
|
+
newsletterDirectoryList: async (options = {}) => {
|
|
358
|
+
const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options;
|
|
359
|
+
const variables = { limit, sort_field: sortField, sort_order: sortOrder };
|
|
360
|
+
if (interests?.length)
|
|
361
|
+
variables.interests = interests;
|
|
362
|
+
return executeWMexQuery(variables, Types_1.QueryIds.DIRECTORY_LIST, Types_1.XWAPaths.xwa2_newsletters_directory_list);
|
|
363
|
+
},
|
|
364
|
+
newsletterDirectorySearch: async (searchText, options = {}) => {
|
|
365
|
+
const { limit = 20, startCursor = null, categories = null } = options;
|
|
366
|
+
const variables = { search_text: searchText, limit };
|
|
367
|
+
if (startCursor)
|
|
368
|
+
variables.start_cursor = startCursor;
|
|
369
|
+
if (categories?.length)
|
|
370
|
+
variables.categories = categories;
|
|
371
|
+
return executeWMexQuery(variables, Types_1.QueryIds.DIRECTORY_SEARCH, Types_1.XWAPaths.xwa2_newsletters_directory_search);
|
|
372
|
+
},
|
|
373
|
+
newsletterDirectoryCategoryPreview: async (limit = 5) => {
|
|
374
|
+
return executeWMexQuery({ limit }, Types_1.QueryIds.DIRECTORY_CATEGORY_PREVIEW, Types_1.XWAPaths.xwa2_newsletters_directory_category_preview);
|
|
375
|
+
},
|
|
376
|
+
newsletterSearch: async (query, limit = 20, startCursor = null) => {
|
|
377
|
+
const variables = { query, limit };
|
|
378
|
+
if (startCursor)
|
|
379
|
+
variables.start_cursor = startCursor;
|
|
380
|
+
return executeWMexQuery(variables, Types_1.QueryIds.SEARCH, Types_1.XWAPaths.xwa2_newsletters_search);
|
|
381
|
+
},
|
|
382
|
+
newsletterRecommended: async (limit = 10, numFollowed = null) => {
|
|
383
|
+
const variables = { limit };
|
|
384
|
+
if (numFollowed != null)
|
|
385
|
+
variables.num_newsletters_followed = numFollowed;
|
|
386
|
+
return executeWMexQuery(variables, Types_1.QueryIds.RECOMMENDED, Types_1.XWAPaths.xwa2_newsletters_recommended);
|
|
387
|
+
},
|
|
388
|
+
newsletterSimilar: async (jid, limit = 10) => {
|
|
389
|
+
return executeWMexQuery({ newsletter_id: jid, limit }, Types_1.QueryIds.SIMILAR, Types_1.XWAPaths.xwa2_newsletters_similar);
|
|
390
|
+
},
|
|
391
|
+
newsletterFollowingList: async (startCursor = null, limit = 20) => {
|
|
392
|
+
const variables = { limit };
|
|
393
|
+
if (startCursor)
|
|
394
|
+
variables.start_cursor = startCursor;
|
|
395
|
+
return executeWMexQuery(variables, Types_1.QueryIds.FOLLOWING_LIST, Types_1.XWAPaths.xwa2_newsletter_following);
|
|
396
|
+
},
|
|
397
|
+
newsletterInsights: async (jid, period = null) => {
|
|
398
|
+
const variables = { newsletter_id: jid };
|
|
399
|
+
if (period)
|
|
400
|
+
variables.period = period;
|
|
401
|
+
return executeWMexQuery(variables, Types_1.QueryIds.INSIGHTS, Types_1.XWAPaths.xwa2_newsletter_admin_insights);
|
|
402
|
+
},
|
|
403
|
+
newsletterPollVoterList: async (jid, serverId, option = null, startCursor = null) => {
|
|
404
|
+
const variables = { id: jid, server_id: serverId };
|
|
405
|
+
if (option != null)
|
|
406
|
+
variables.option = option;
|
|
407
|
+
if (startCursor)
|
|
408
|
+
variables.start_cursor = startCursor;
|
|
409
|
+
return executeWMexQuery(variables, Types_1.QueryIds.POLL_VOTER_LIST, Types_1.XWAPaths.xwa2_newsletters_poll_voter_list);
|
|
410
|
+
},
|
|
411
|
+
newsletterReactionSenders: async (jid, serverId, startCursor = null) => {
|
|
412
|
+
const variables = { id: jid, server_id: serverId };
|
|
413
|
+
if (startCursor)
|
|
414
|
+
variables.start_cursor = startCursor;
|
|
415
|
+
return executeWMexQuery(variables, Types_1.QueryIds.REACTION_SENDERS_LIST, Types_1.XWAPaths.xwa2_newsletters_reaction_sender_list);
|
|
416
|
+
},
|
|
417
|
+
newsletterBlockUser: async (jid, userJid) => {
|
|
418
|
+
return executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.BLOCK_USER, 'xwa2_newsletter_block_user');
|
|
419
|
+
},
|
|
420
|
+
newsletterEnableWamo: async (jid) => {
|
|
421
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ENABLE_SUB, 'xwa2_newsletter_wamo_enable_sub');
|
|
422
|
+
},
|
|
423
|
+
newsletterDisableWamo: async (jid) => {
|
|
424
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_DISABLE_SUB, 'xwa2_newsletter_wamo_disable_sub');
|
|
425
|
+
},
|
|
426
|
+
newsletterChangeWamo: async (jid, subConfig) => {
|
|
427
|
+
return executeWMexQuery({ newsletter_id: jid, ...subConfig }, Types_1.QueryIds.WAMO_CHANGE_SUB, 'xwa2_newsletter_wamo_change_sub');
|
|
428
|
+
},
|
|
429
|
+
wamoAfsAgeCollection: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION, Types_1.XWAPaths.xwa2_wamo_afs_age_collection),
|
|
430
|
+
wamoAssetCollection: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ASSET_COLLECTION, Types_1.XWAPaths.xwa2_wamo_asset_collection),
|
|
431
|
+
wamoFetchAdhocNotice: async (noticeId) => executeWMexQuery({ notice_id: noticeId }, Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE, Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id),
|
|
432
|
+
wamoFetchIdentityToken: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN, Types_1.XWAPaths.xwa2_wamo_fetch_identity_token),
|
|
433
|
+
wamoSubComplianceInfo: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO, Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info),
|
|
434
|
+
wamoUserIdVersion: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_user_id_version),
|
|
435
|
+
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),
|
|
436
|
+
newsletterLeave: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.LEAVE, Types_1.XWAPaths.xwa2_newsletter_leave_v2),
|
|
437
|
+
newsletterCreateVerified: async (name, description = null) => executeWMexQuery({ input: { name, description } }, Types_1.QueryIds.CREATE_VERIFIED, Types_1.XWAPaths.xwa2_newsletter_create_verified),
|
|
438
|
+
newsletterEnforcements: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ENFORCEMENTS, Types_1.XWAPaths.xwa2_newsletter_enforcements),
|
|
439
|
+
newsletterUserReports: async (jid, cursor = null) => {
|
|
440
|
+
const variables = { newsletter_id: jid };
|
|
441
|
+
if (cursor)
|
|
442
|
+
variables.cursor = cursor;
|
|
443
|
+
return executeWMexQuery(variables, Types_1.QueryIds.USER_REPORTS, Types_1.XWAPaths.xwa2_newsletter_user_reports);
|
|
444
|
+
},
|
|
445
|
+
newsletterCreateReportAppeal: async (jid, reason) => executeWMexQuery({ newsletter_id: jid, reason }, Types_1.QueryIds.CREATE_REPORT_APPEAL, Types_1.XWAPaths.xwa2_newsletter_create_report_appeal),
|
|
446
|
+
newsletterLinkPreviewCheck: async (url) => executeWMexQuery({ url }, Types_1.QueryIds.LINK_PREVIEW_CHECK, Types_1.XWAPaths.xwa2_newsletter_link_preview_check),
|
|
447
|
+
newsletterUpdateVerification: async (jid, verification) => executeWMexQuery({ newsletter_id: jid, verification }, Types_1.QueryIds.UPDATE_VERIFICATION, Types_1.XWAPaths.xwa2_newsletter_update_verification),
|
|
448
|
+
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),
|
|
449
|
+
newsletterLogExposures: async (events) => executeWMexQuery({ events }, Types_1.QueryIds.LOG_EXPOSURES, Types_1.XWAPaths.xwa2_newsletter_log_exposures),
|
|
450
|
+
newsletterUpdateUserSetting: async (jid, setting) => executeWMexQuery({ newsletter_id: jid, ...setting }, Types_1.QueryIds.UPDATE_USER_SETTING, Types_1.XWAPaths.xwa2_newsletter_update_user_setting),
|
|
451
|
+
newsletterRankingFeatures: async (jid) => executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.RANKING_FEATURES, Types_1.XWAPaths.xwa2_newsletter_ranking_features),
|
|
452
|
+
newsletterSendViewReceipt: async (jid, serverMessageIds) => {
|
|
453
|
+
const ids = Array.isArray(serverMessageIds) ? serverMessageIds : [serverMessageIds];
|
|
454
|
+
const receiptId = generateMessageTag();
|
|
455
|
+
await query({
|
|
456
|
+
tag: 'receipt',
|
|
457
|
+
attrs: {
|
|
458
|
+
to: jid,
|
|
459
|
+
id: receiptId,
|
|
460
|
+
type: 'view'
|
|
461
|
+
},
|
|
462
|
+
content: [
|
|
463
|
+
{
|
|
464
|
+
tag: 'list',
|
|
465
|
+
attrs: {},
|
|
466
|
+
content: ids.map(id => ({ tag: 'item', attrs: { server_id: String(id) } }))
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.USyncPictureProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require('../../WABinary');
|
|
5
|
+
class USyncPictureProtocol {
|
|
6
|
+
constructor(type = 'image') {
|
|
7
|
+
this.name = 'picture';
|
|
8
|
+
this.type = type;
|
|
9
|
+
}
|
|
10
|
+
getQueryElement() {
|
|
11
|
+
return {
|
|
12
|
+
tag: 'picture',
|
|
13
|
+
attrs: { type: this.type }
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
getUserElement(user) {
|
|
17
|
+
const attrs = {};
|
|
18
|
+
if (user.pictureId != null)
|
|
19
|
+
attrs.id = String(user.pictureId);
|
|
20
|
+
return Object.keys(attrs).length > 0 ? { tag: 'picture', attrs } : null;
|
|
21
|
+
}
|
|
22
|
+
parser(node) {
|
|
23
|
+
if (node.tag !== 'picture')
|
|
24
|
+
return null;
|
|
25
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
26
|
+
const id = node.attrs?.id ?? null;
|
|
27
|
+
const directPath = node.attrs?.direct_path ?? null;
|
|
28
|
+
const hash = node.attrs?.hash ?? null;
|
|
29
|
+
if (!id && !directPath)
|
|
30
|
+
return null;
|
|
31
|
+
return { id, directPath, hash };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.USyncPictureProtocol = USyncPictureProtocol;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.USyncSidelistProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require('../../WABinary');
|
|
5
|
+
class USyncSidelistProtocol {
|
|
6
|
+
constructor(useLidAddressing = true) {
|
|
7
|
+
this.name = 'sidelist';
|
|
8
|
+
this.useLidAddressing = useLidAddressing;
|
|
9
|
+
}
|
|
10
|
+
getQueryElement() {
|
|
11
|
+
const attrs = {};
|
|
12
|
+
if (this.useLidAddressing)
|
|
13
|
+
attrs.addressing_mode = 'lid';
|
|
14
|
+
return { tag: 'sidelist', attrs };
|
|
15
|
+
}
|
|
16
|
+
getUserElement(user) {
|
|
17
|
+
if (user.sidelistDelete) {
|
|
18
|
+
return { tag: 'sidelist', attrs: { type: 'delete' } };
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
parser(node) {
|
|
23
|
+
if (node.tag !== 'sidelist' && node.tag !== 'side_list')
|
|
24
|
+
return null;
|
|
25
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
26
|
+
return { type: node.attrs?.type ?? null };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.USyncSidelistProtocol = USyncSidelistProtocol;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.USyncStatusProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require('../../WABinary');
|
|
5
|
+
class USyncStatusProtocol {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'status';
|
|
8
|
+
}
|
|
9
|
+
getQueryElement() {
|
|
10
|
+
return {
|
|
11
|
+
tag: 'status',
|
|
12
|
+
attrs: {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getUserElement() {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
parser(node) {
|
|
19
|
+
if (node.tag === 'status') {
|
|
20
|
+
;
|
|
21
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
22
|
+
let status = node?.content?.toString() ?? null;
|
|
23
|
+
const setAt = new Date(+(node?.attrs.t || 0) * 1000);
|
|
24
|
+
if (!status) {
|
|
25
|
+
if (node.attrs?.code && +node.attrs.code === 401) {
|
|
26
|
+
status = '';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
status = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (typeof status === 'string' && status.length === 0) {
|
|
33
|
+
status = null;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
status,
|
|
37
|
+
setAt
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.USyncStatusProtocol = USyncStatusProtocol;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.USyncTextStatusProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require('../../WABinary');
|
|
5
|
+
class USyncTextStatusProtocol {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'text_status';
|
|
8
|
+
}
|
|
9
|
+
getQueryElement() {
|
|
10
|
+
return {
|
|
11
|
+
tag: 'text_status',
|
|
12
|
+
attrs: {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getUserElement() {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
parser(node) {
|
|
19
|
+
if (node.tag !== 'text_status')
|
|
20
|
+
return null;
|
|
21
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
22
|
+
const lastUpdateTimeSec = node.attrs?.last_update_time ? +node.attrs.last_update_time : 0;
|
|
23
|
+
const ephemeralDurationSec = node.attrs?.ephemeral_duration_sec ? +node.attrs.ephemeral_duration_sec : 0;
|
|
24
|
+
const text = node.attrs?.text ?? null;
|
|
25
|
+
const emojiNode = (0, WABinary_1.getBinaryNodeChild)(node, 'emoji');
|
|
26
|
+
const emoji = emojiNode?.attrs?.content ?? null;
|
|
27
|
+
const expiresAt = ephemeralDurationSec > 0
|
|
28
|
+
? new Date((lastUpdateTimeSec + ephemeralDurationSec) * 1000)
|
|
29
|
+
: null;
|
|
30
|
+
return {
|
|
31
|
+
text,
|
|
32
|
+
emoji,
|
|
33
|
+
setAt: new Date(lastUpdateTimeSec * 1000),
|
|
34
|
+
expiresAt
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.USyncTextStatusProtocol = USyncTextStatusProtocol;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.USyncUsernameProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require('../../WABinary');
|
|
5
|
+
class USyncUsernameProtocol {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'username';
|
|
8
|
+
}
|
|
9
|
+
getQueryElement() {
|
|
10
|
+
return {
|
|
11
|
+
tag: 'username',
|
|
12
|
+
attrs: {}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getUserElement(user) {
|
|
16
|
+
void user;
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
parser(node) {
|
|
20
|
+
if (node.tag === 'username') {
|
|
21
|
+
;
|
|
22
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
23
|
+
return typeof node.content === 'string' ? node.content : null;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.USyncUsernameProtocol = USyncUsernameProtocol;
|