@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
package/lib/Socket/newsletter.js
DELETED
|
@@ -1,814 +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
|
-
|
|
11
|
-
|
|
12
|
-
const mapNewsletterRole = raw => {
|
|
13
|
-
if (!raw) return Types_1.NewsletterRole.GUEST
|
|
14
|
-
const upper = String(raw).toUpperCase()
|
|
15
|
-
switch (upper) {
|
|
16
|
-
case 'OWNER':
|
|
17
|
-
return Types_1.NewsletterRole.OWNER
|
|
18
|
-
case 'ADMIN':
|
|
19
|
-
return Types_1.NewsletterRole.ADMIN
|
|
20
|
-
case 'SUBSCRIBER':
|
|
21
|
-
return Types_1.NewsletterRole.SUBSCRIBER
|
|
22
|
-
default:
|
|
23
|
-
return Types_1.NewsletterRole.GUEST
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const mapNewsletterState = raw => {
|
|
29
|
-
if (!raw) return Types_1.NewsletterState.UNKNOWN
|
|
30
|
-
const upper = String(raw).toUpperCase()
|
|
31
|
-
switch (upper) {
|
|
32
|
-
case 'ACTIVE':
|
|
33
|
-
return Types_1.NewsletterState.ACTIVE
|
|
34
|
-
case 'SUSPENDED':
|
|
35
|
-
return Types_1.NewsletterState.SUSPENDED
|
|
36
|
-
case 'GEO_SUSPENDED':
|
|
37
|
-
return Types_1.NewsletterState.GEO_SUSPENDED
|
|
38
|
-
default:
|
|
39
|
-
return Types_1.NewsletterState.UNKNOWN
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const mapReactionSetting = raw => {
|
|
45
|
-
if (!raw) return Types_1.NewsletterReactionSetting.NONE
|
|
46
|
-
const upper = String(raw).toUpperCase()
|
|
47
|
-
switch (upper) {
|
|
48
|
-
case 'ALLOWLIST':
|
|
49
|
-
return Types_1.NewsletterReactionSetting.ALLOWLIST
|
|
50
|
-
case 'BLOCKLIST':
|
|
51
|
-
return Types_1.NewsletterReactionSetting.BLOCKLIST
|
|
52
|
-
default:
|
|
53
|
-
return Types_1.NewsletterReactionSetting.NONE
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const mergeDsaCountries = (a, b) => {
|
|
59
|
-
if (!a && !b) return null
|
|
60
|
-
const merged = [...(Array.isArray(a) ? a : a ? [a] : []), ...(Array.isArray(b) ? b : b ? [b] : [])]
|
|
61
|
-
return merged.length ? [...new Set(merged)] : null
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const enrichNewsletterMetadata = raw => {
|
|
65
|
-
if (!raw || typeof raw !== 'object') return raw
|
|
66
|
-
const thread = raw.thread_metadata || {}
|
|
67
|
-
const viewer = raw.viewer_metadata || {}
|
|
68
|
-
const dsaCountries = mergeDsaCountries(
|
|
69
|
-
thread.dsa_eligibility_countries ?? raw.dsa_eligibility_countries ?? null,
|
|
70
|
-
thread.dsa_eligible_countries ?? raw.dsa_eligible_countries ?? null
|
|
71
|
-
)
|
|
72
|
-
return {
|
|
73
|
-
...raw,
|
|
74
|
-
role: mapNewsletterRole(viewer.role ?? raw.role),
|
|
75
|
-
newsletterState: mapNewsletterState(raw.state ?? thread.state),
|
|
76
|
-
reactionSetting: mapReactionSetting(
|
|
77
|
-
thread.reaction_codes ?? thread.reaction_setting ?? raw.reaction_codes ?? raw.reaction_setting
|
|
78
|
-
),
|
|
79
|
-
dsaEligibilityCountries: dsaCountries,
|
|
80
|
-
dsaDecision: thread.dsa_decision ?? raw.dsa_decision ?? null,
|
|
81
|
-
pinnedMessage:
|
|
82
|
-
thread.pinned_message_server_id ??
|
|
83
|
-
thread.pinned_message_id ??
|
|
84
|
-
raw.pinned_message_server_id ??
|
|
85
|
-
raw.pinned_message_id ??
|
|
86
|
-
null,
|
|
87
|
-
hasQuestionsFeature: !!(thread.has_questions_feature ?? raw.has_questions_feature ?? false),
|
|
88
|
-
hasMusicFeature: !!(
|
|
89
|
-
thread.has_music_feature ??
|
|
90
|
-
thread.music_enabled ??
|
|
91
|
-
raw.has_music_feature ??
|
|
92
|
-
raw.music_enabled ??
|
|
93
|
-
false
|
|
94
|
-
),
|
|
95
|
-
viewsCount:
|
|
96
|
-
thread.views_count != null
|
|
97
|
-
? parseInt(thread.views_count, 10)
|
|
98
|
-
: raw.views_count != null
|
|
99
|
-
? parseInt(raw.views_count, 10)
|
|
100
|
-
: null,
|
|
101
|
-
subscriberCount:
|
|
102
|
-
thread.subscriber_count != null
|
|
103
|
-
? parseInt(thread.subscriber_count, 10)
|
|
104
|
-
: raw.subscriber_count != null
|
|
105
|
-
? parseInt(raw.subscriber_count, 10)
|
|
106
|
-
: null
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const parseNewsletterCreateResponse = response => {
|
|
111
|
-
const { id, thread_metadata: thread, viewer_metadata: viewer } = response
|
|
112
|
-
const dsaCountries = mergeDsaCountries(
|
|
113
|
-
thread.dsa_eligibility_countries ?? null,
|
|
114
|
-
thread.dsa_eligible_countries ?? null
|
|
115
|
-
)
|
|
116
|
-
const base = {
|
|
117
|
-
id: id,
|
|
118
|
-
owner: undefined,
|
|
119
|
-
name: thread.name.text,
|
|
120
|
-
creation_time: parseInt(thread.creation_time, 10),
|
|
121
|
-
description: thread.description.text,
|
|
122
|
-
invite: thread.invite,
|
|
123
|
-
subscribers: parseInt(thread.subscribers_count, 10),
|
|
124
|
-
verification: thread.verification,
|
|
125
|
-
picture: {
|
|
126
|
-
id: thread.picture.id,
|
|
127
|
-
directPath: thread.picture.direct_path
|
|
128
|
-
},
|
|
129
|
-
mute_state: viewer.mute,
|
|
130
|
-
role: mapNewsletterRole(viewer.role),
|
|
131
|
-
newsletterState: mapNewsletterState(thread.state),
|
|
132
|
-
reactionSetting: mapReactionSetting(thread.reaction_codes ?? thread.reaction_setting),
|
|
133
|
-
dsaEligibilityCountries: dsaCountries,
|
|
134
|
-
dsaDecision: thread.dsa_decision ?? null,
|
|
135
|
-
pinnedMessage: thread.pinned_message_server_id ?? thread.pinned_message_id ?? null,
|
|
136
|
-
hasQuestionsFeature: !!(thread.has_questions_feature ?? false),
|
|
137
|
-
hasMusicFeature: !!(thread.has_music_feature ?? thread.music_enabled ?? false)
|
|
138
|
-
}
|
|
139
|
-
return base
|
|
140
|
-
}
|
|
141
|
-
const parseNewsletterMetadata = result => {
|
|
142
|
-
if (typeof result !== 'object' || result === null) {
|
|
143
|
-
return null
|
|
144
|
-
}
|
|
145
|
-
if ('id' in result && typeof result.id === 'string') {
|
|
146
|
-
return enrichNewsletterMetadata(result)
|
|
147
|
-
}
|
|
148
|
-
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
149
|
-
return enrichNewsletterMetadata(result.result)
|
|
150
|
-
}
|
|
151
|
-
return null
|
|
152
|
-
}
|
|
153
|
-
const makeNewsletterSocket = config => {
|
|
154
|
-
const sock = (0, aigroups_1.makeAIGroupsSocket)(config)
|
|
155
|
-
const { query, generateMessageTag, sendNode } = sock
|
|
156
|
-
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
157
|
-
return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag)
|
|
158
|
-
}
|
|
159
|
-
const newsletterUpdate = async (jid, updates) => {
|
|
160
|
-
const variables = {
|
|
161
|
-
newsletter_id: jid,
|
|
162
|
-
updates: {
|
|
163
|
-
...updates,
|
|
164
|
-
settings: null
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
...sock,
|
|
171
|
-
newsletterCreate: async (name, description) => {
|
|
172
|
-
const variables = {
|
|
173
|
-
input: {
|
|
174
|
-
name,
|
|
175
|
-
description: description ?? null
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
const rawResponse = await executeWMexQuery(
|
|
179
|
-
variables,
|
|
180
|
-
Types_1.QueryIds.CREATE,
|
|
181
|
-
Types_1.XWAPaths.xwa2_newsletter_create
|
|
182
|
-
)
|
|
183
|
-
return parseNewsletterCreateResponse(rawResponse)
|
|
184
|
-
},
|
|
185
|
-
newsletterUpdate,
|
|
186
|
-
newsletterSubscribers: async jid => {
|
|
187
|
-
return executeWMexQuery(
|
|
188
|
-
{ newsletter_id: jid },
|
|
189
|
-
Types_1.QueryIds.SUBSCRIBERS,
|
|
190
|
-
Types_1.XWAPaths.xwa2_newsletter_followers
|
|
191
|
-
)
|
|
192
|
-
},
|
|
193
|
-
newsletterMetadata: async (type, key) => {
|
|
194
|
-
const variables = {
|
|
195
|
-
fetch_creation_time: true,
|
|
196
|
-
fetch_full_image: true,
|
|
197
|
-
fetch_viewer_metadata: true,
|
|
198
|
-
input: {
|
|
199
|
-
key,
|
|
200
|
-
type: type.toUpperCase()
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
const result = await executeWMexQuery(
|
|
204
|
-
variables,
|
|
205
|
-
Types_1.QueryIds.METADATA,
|
|
206
|
-
Types_1.XWAPaths.xwa2_newsletter_metadata
|
|
207
|
-
)
|
|
208
|
-
return parseNewsletterMetadata(result)
|
|
209
|
-
},
|
|
210
|
-
newsletterFollow: jid => {
|
|
211
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_join_v2)
|
|
212
|
-
},
|
|
213
|
-
newsletterUnfollow: jid => {
|
|
214
|
-
return executeWMexQuery(
|
|
215
|
-
{ newsletter_id: jid },
|
|
216
|
-
Types_1.QueryIds.UNFOLLOW,
|
|
217
|
-
Types_1.XWAPaths.xwa2_newsletter_leave_v2
|
|
218
|
-
)
|
|
219
|
-
},
|
|
220
|
-
newsletterMute: jid => {
|
|
221
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.MUTE, Types_1.XWAPaths.xwa2_newsletter_mute_v2)
|
|
222
|
-
},
|
|
223
|
-
newsletterUnmute: jid => {
|
|
224
|
-
return executeWMexQuery(
|
|
225
|
-
{ newsletter_id: jid },
|
|
226
|
-
Types_1.QueryIds.UNMUTE,
|
|
227
|
-
Types_1.XWAPaths.xwa2_newsletter_unmute_v2
|
|
228
|
-
)
|
|
229
|
-
},
|
|
230
|
-
newsletterUpdateName: async (jid, name) => {
|
|
231
|
-
return await newsletterUpdate(jid, { name })
|
|
232
|
-
},
|
|
233
|
-
newsletterUpdateDescription: async (jid, description) => {
|
|
234
|
-
return await newsletterUpdate(jid, { description })
|
|
235
|
-
},
|
|
236
|
-
newsletterUpdatePicture: async (jid, content) => {
|
|
237
|
-
const { img } = await (0, messages_media_1.generateProfilePicture)(content)
|
|
238
|
-
return await newsletterUpdate(jid, { picture: img.toString('base64') })
|
|
239
|
-
},
|
|
240
|
-
newsletterRemovePicture: async jid => {
|
|
241
|
-
return await newsletterUpdate(jid, { picture: '' })
|
|
242
|
-
},
|
|
243
|
-
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
244
|
-
await query({
|
|
245
|
-
tag: 'message',
|
|
246
|
-
attrs: {
|
|
247
|
-
to: jid,
|
|
248
|
-
...(reaction ? {} : { edit: '7' }),
|
|
249
|
-
type: 'reaction',
|
|
250
|
-
server_id: serverId,
|
|
251
|
-
id: generateMessageTag()
|
|
252
|
-
},
|
|
253
|
-
content: [
|
|
254
|
-
{
|
|
255
|
-
tag: 'reaction',
|
|
256
|
-
attrs: reaction ? { code: reaction } : {}
|
|
257
|
-
}
|
|
258
|
-
]
|
|
259
|
-
})
|
|
260
|
-
},
|
|
261
|
-
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
262
|
-
const messageUpdateAttrs = {
|
|
263
|
-
count: count.toString()
|
|
264
|
-
}
|
|
265
|
-
if (typeof since === 'number') {
|
|
266
|
-
messageUpdateAttrs.since = since.toString()
|
|
267
|
-
}
|
|
268
|
-
if (after) {
|
|
269
|
-
messageUpdateAttrs.after = after.toString()
|
|
270
|
-
}
|
|
271
|
-
const result = await query({
|
|
272
|
-
tag: 'iq',
|
|
273
|
-
attrs: {
|
|
274
|
-
id: generateMessageTag(),
|
|
275
|
-
type: 'get',
|
|
276
|
-
xmlns: 'newsletter',
|
|
277
|
-
to: jid
|
|
278
|
-
},
|
|
279
|
-
content: [
|
|
280
|
-
{
|
|
281
|
-
tag: 'message_updates',
|
|
282
|
-
attrs: messageUpdateAttrs
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
})
|
|
286
|
-
return result
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
newsletterGetServerId: async (jid, messageId, limit = 50) => {
|
|
290
|
-
console.log('[newsletterGetServerId] called jid:', jid, 'messageId:', messageId)
|
|
291
|
-
let result
|
|
292
|
-
try {
|
|
293
|
-
result = await query(
|
|
294
|
-
{
|
|
295
|
-
tag: 'iq',
|
|
296
|
-
attrs: {
|
|
297
|
-
id: generateMessageTag(),
|
|
298
|
-
type: 'get',
|
|
299
|
-
xmlns: 'newsletter',
|
|
300
|
-
to: jid
|
|
301
|
-
},
|
|
302
|
-
content: [{ tag: 'message_updates', attrs: { count: String(limit) } }]
|
|
303
|
-
},
|
|
304
|
-
5000
|
|
305
|
-
)
|
|
306
|
-
} catch (e) {
|
|
307
|
-
console.log('[newsletterGetServerId] query error/timeout:', e?.message)
|
|
308
|
-
return null
|
|
309
|
-
}
|
|
310
|
-
console.log('[newsletterGetServerId] result tag:', result?.tag, 'attrs:', JSON.stringify(result?.attrs))
|
|
311
|
-
if (!result) return null
|
|
312
|
-
const updatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'message_updates')
|
|
313
|
-
const messages = (0, WABinary_1.getBinaryNodeChildren)(updatesNode ?? result, 'message')
|
|
314
|
-
console.log(
|
|
315
|
-
'[newsletterGetServerId] messages count:',
|
|
316
|
-
messages.length,
|
|
317
|
-
'first attrs:',
|
|
318
|
-
JSON.stringify(messages[0]?.attrs)
|
|
319
|
-
)
|
|
320
|
-
for (const msg of messages) {
|
|
321
|
-
if (msg.attrs.message_id === messageId || msg.attrs.id === messageId) {
|
|
322
|
-
return msg.attrs.server_id ? +msg.attrs.server_id : null
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return null
|
|
326
|
-
},
|
|
327
|
-
subscribeNewsletterUpdates: async jid => {
|
|
328
|
-
const result = await query({
|
|
329
|
-
tag: 'iq',
|
|
330
|
-
attrs: {
|
|
331
|
-
id: generateMessageTag(),
|
|
332
|
-
type: 'set',
|
|
333
|
-
xmlns: 'newsletter',
|
|
334
|
-
to: jid
|
|
335
|
-
},
|
|
336
|
-
content: [{ tag: 'live_updates', attrs: {}, content: [] }]
|
|
337
|
-
})
|
|
338
|
-
const liveUpdatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')
|
|
339
|
-
const duration = liveUpdatesNode?.attrs?.duration
|
|
340
|
-
return duration ? { duration: duration } : null
|
|
341
|
-
},
|
|
342
|
-
newsletterAdminCount: async jid => {
|
|
343
|
-
const response = await executeWMexQuery(
|
|
344
|
-
{ newsletter_id: jid },
|
|
345
|
-
Types_1.QueryIds.ADMIN_COUNT,
|
|
346
|
-
Types_1.XWAPaths.xwa2_newsletter_admin_count
|
|
347
|
-
)
|
|
348
|
-
return response.admin_count
|
|
349
|
-
},
|
|
350
|
-
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
351
|
-
await executeWMexQuery(
|
|
352
|
-
{ newsletter_id: jid, user_id: newOwnerJid },
|
|
353
|
-
Types_1.QueryIds.CHANGE_OWNER,
|
|
354
|
-
Types_1.XWAPaths.xwa2_newsletter_change_owner
|
|
355
|
-
)
|
|
356
|
-
},
|
|
357
|
-
newsletterDemote: async (jid, userJid) => {
|
|
358
|
-
await executeWMexQuery(
|
|
359
|
-
{ newsletter_id: jid, user_id: userJid },
|
|
360
|
-
Types_1.QueryIds.DEMOTE,
|
|
361
|
-
Types_1.XWAPaths.xwa2_newsletter_admin_demote
|
|
362
|
-
)
|
|
363
|
-
},
|
|
364
|
-
newsletterDelete: async jid => {
|
|
365
|
-
await executeWMexQuery(
|
|
366
|
-
{ newsletter_id: jid },
|
|
367
|
-
Types_1.QueryIds.DELETE,
|
|
368
|
-
Types_1.XWAPaths.xwa2_newsletter_delete_v2
|
|
369
|
-
)
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
newsletterUpdateCategory: async (jid, category) => {
|
|
373
|
-
return newsletterUpdate(jid, { topic: category })
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
newsletterUpdateSettings: async (jid, settings) => {
|
|
377
|
-
const variables = { newsletter_id: jid, updates: { settings } }
|
|
378
|
-
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
newsletterPromoteAdmin: async (jid, userJid) => {
|
|
382
|
-
await query({
|
|
383
|
-
tag: 'iq',
|
|
384
|
-
attrs: {
|
|
385
|
-
id: generateMessageTag(),
|
|
386
|
-
type: 'set',
|
|
387
|
-
xmlns: 'newsletter',
|
|
388
|
-
to: jid
|
|
389
|
-
},
|
|
390
|
-
content: [
|
|
391
|
-
{
|
|
392
|
-
tag: 'admin_promote',
|
|
393
|
-
attrs: {},
|
|
394
|
-
content: [{ tag: 'participant', attrs: { jid: userJid } }]
|
|
395
|
-
}
|
|
396
|
-
]
|
|
397
|
-
})
|
|
398
|
-
},
|
|
399
|
-
|
|
400
|
-
newsletterViewStats: async (jid, serverId) => {
|
|
401
|
-
const result = await query({
|
|
402
|
-
tag: 'iq',
|
|
403
|
-
attrs: {
|
|
404
|
-
id: generateMessageTag(),
|
|
405
|
-
type: 'get',
|
|
406
|
-
xmlns: 'newsletter',
|
|
407
|
-
to: jid
|
|
408
|
-
},
|
|
409
|
-
content: [
|
|
410
|
-
{
|
|
411
|
-
tag: 'message_updates',
|
|
412
|
-
attrs: { count: '1', server_id: String(serverId) }
|
|
413
|
-
}
|
|
414
|
-
]
|
|
415
|
-
})
|
|
416
|
-
return result
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
newsletterSendPost: async (jid, content, options = {}) => {
|
|
420
|
-
const result = await query({
|
|
421
|
-
tag: 'iq',
|
|
422
|
-
attrs: {
|
|
423
|
-
id: generateMessageTag(),
|
|
424
|
-
type: 'set',
|
|
425
|
-
xmlns: 'newsletter',
|
|
426
|
-
to: jid
|
|
427
|
-
},
|
|
428
|
-
content: [
|
|
429
|
-
{
|
|
430
|
-
tag: 'publish',
|
|
431
|
-
attrs: {},
|
|
432
|
-
content: Array.isArray(content) ? content : [content]
|
|
433
|
-
}
|
|
434
|
-
]
|
|
435
|
-
})
|
|
436
|
-
return result
|
|
437
|
-
},
|
|
438
|
-
|
|
439
|
-
newsletterRevokeMessage: async (jid, serverId) => {
|
|
440
|
-
await sendNode({
|
|
441
|
-
tag: 'message',
|
|
442
|
-
attrs: {
|
|
443
|
-
to: jid,
|
|
444
|
-
type: 'text',
|
|
445
|
-
edit: '7',
|
|
446
|
-
server_id: String(serverId),
|
|
447
|
-
id: generateMessageTag()
|
|
448
|
-
},
|
|
449
|
-
content: []
|
|
450
|
-
})
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
newsletterPinMessage: async (jid, serverId, durationSecs = 86400) => {
|
|
454
|
-
await query({
|
|
455
|
-
tag: 'iq',
|
|
456
|
-
attrs: {
|
|
457
|
-
id: generateMessageTag(),
|
|
458
|
-
type: 'set',
|
|
459
|
-
xmlns: 'newsletter',
|
|
460
|
-
to: jid
|
|
461
|
-
},
|
|
462
|
-
content: [
|
|
463
|
-
{
|
|
464
|
-
tag: 'pin',
|
|
465
|
-
attrs: { server_id: String(serverId), duration: String(durationSecs) }
|
|
466
|
-
}
|
|
467
|
-
]
|
|
468
|
-
})
|
|
469
|
-
},
|
|
470
|
-
|
|
471
|
-
newsletterUnpinMessage: async (jid, serverId) => {
|
|
472
|
-
await query({
|
|
473
|
-
tag: 'iq',
|
|
474
|
-
attrs: {
|
|
475
|
-
id: generateMessageTag(),
|
|
476
|
-
type: 'set',
|
|
477
|
-
xmlns: 'newsletter',
|
|
478
|
-
to: jid
|
|
479
|
-
},
|
|
480
|
-
content: [
|
|
481
|
-
{
|
|
482
|
-
tag: 'unpin',
|
|
483
|
-
attrs: { server_id: String(serverId) }
|
|
484
|
-
}
|
|
485
|
-
]
|
|
486
|
-
})
|
|
487
|
-
},
|
|
488
|
-
|
|
489
|
-
newsletterInviteAdmin: async (jid, userJid) => {
|
|
490
|
-
return executeWMexQuery(
|
|
491
|
-
{ newsletter_id: jid, user_id: userJid },
|
|
492
|
-
Types_1.QueryIds.ADMIN_INVITE,
|
|
493
|
-
Types_1.XWAPaths.xwa2_newsletter_admin_invite_create
|
|
494
|
-
)
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
newsletterRevokeAdminInvite: async (jid, userJid) => {
|
|
498
|
-
return executeWMexQuery(
|
|
499
|
-
{ newsletter_id: jid, user_id: userJid },
|
|
500
|
-
Types_1.QueryIds.ADMIN_INVITE_REVOKE,
|
|
501
|
-
Types_1.XWAPaths.xwa2_newsletter_admin_invite_revoke
|
|
502
|
-
)
|
|
503
|
-
},
|
|
504
|
-
|
|
505
|
-
newsletterAcceptAdminInvite: async jid => {
|
|
506
|
-
return executeWMexQuery(
|
|
507
|
-
{ newsletter_id: jid },
|
|
508
|
-
Types_1.QueryIds.ADMIN_INVITE_ACCEPT,
|
|
509
|
-
Types_1.XWAPaths.xwa2_newsletter_admin_invite_accept
|
|
510
|
-
)
|
|
511
|
-
},
|
|
512
|
-
|
|
513
|
-
newsletterAdminMetadata: async (jid, options = {}) => {
|
|
514
|
-
const {
|
|
515
|
-
fetchPendingAdmins = true,
|
|
516
|
-
fetchAdminCount = true,
|
|
517
|
-
fetchCapabilities = false,
|
|
518
|
-
fetchAdminProfile = false,
|
|
519
|
-
includeAdminSettings = false,
|
|
520
|
-
includeJarvisConfig = false
|
|
521
|
-
} = options
|
|
522
|
-
return executeWMexQuery(
|
|
523
|
-
{
|
|
524
|
-
jid,
|
|
525
|
-
include_thread_metadata: false,
|
|
526
|
-
include_messages: false,
|
|
527
|
-
fetch_pending_admin_invites: fetchPendingAdmins,
|
|
528
|
-
fetch_admin_count: fetchAdminCount,
|
|
529
|
-
fetch_capabilities: fetchCapabilities,
|
|
530
|
-
fetch_admin_profile: fetchAdminProfile,
|
|
531
|
-
include_admin_settings: includeAdminSettings,
|
|
532
|
-
include_jarvis_config: includeJarvisConfig
|
|
533
|
-
},
|
|
534
|
-
Types_1.QueryIds.ADMIN_METADATA,
|
|
535
|
-
Types_1.XWAPaths.xwa2_newsletter_admin
|
|
536
|
-
)
|
|
537
|
-
},
|
|
538
|
-
|
|
539
|
-
newsletterAdminProfileUpdate: async (jid, updates) => {
|
|
540
|
-
return executeWMexQuery(
|
|
541
|
-
{ newsletter_id: jid, updates },
|
|
542
|
-
Types_1.QueryIds.ADMIN_PROFILE_UPDATE,
|
|
543
|
-
Types_1.XWAPaths.xwa2_newsletter_admin_profile_update
|
|
544
|
-
)
|
|
545
|
-
},
|
|
546
|
-
|
|
547
|
-
newsletterDirectoryList: async (options = {}) => {
|
|
548
|
-
const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options
|
|
549
|
-
const variables = { limit, sort_field: sortField, sort_order: sortOrder }
|
|
550
|
-
if (interests?.length) variables.interests = interests
|
|
551
|
-
return executeWMexQuery(
|
|
552
|
-
variables,
|
|
553
|
-
Types_1.QueryIds.DIRECTORY_LIST,
|
|
554
|
-
Types_1.XWAPaths.xwa2_newsletters_directory_list
|
|
555
|
-
)
|
|
556
|
-
},
|
|
557
|
-
|
|
558
|
-
newsletterDirectorySearch: async (searchText, options = {}) => {
|
|
559
|
-
const { limit = 20, startCursor = null, categories = null } = options
|
|
560
|
-
const variables = { search_text: searchText, limit }
|
|
561
|
-
if (startCursor) variables.start_cursor = startCursor
|
|
562
|
-
if (categories?.length) variables.categories = categories
|
|
563
|
-
return executeWMexQuery(
|
|
564
|
-
variables,
|
|
565
|
-
Types_1.QueryIds.DIRECTORY_SEARCH,
|
|
566
|
-
Types_1.XWAPaths.xwa2_newsletters_directory_search
|
|
567
|
-
)
|
|
568
|
-
},
|
|
569
|
-
|
|
570
|
-
newsletterDirectoryCategoryPreview: async (limit = 5) => {
|
|
571
|
-
return executeWMexQuery(
|
|
572
|
-
{ limit },
|
|
573
|
-
Types_1.QueryIds.DIRECTORY_CATEGORY_PREVIEW,
|
|
574
|
-
Types_1.XWAPaths.xwa2_newsletters_directory_category_preview
|
|
575
|
-
)
|
|
576
|
-
},
|
|
577
|
-
|
|
578
|
-
newsletterSearch: async (query, limit = 20, startCursor = null) => {
|
|
579
|
-
const variables = { query, limit }
|
|
580
|
-
if (startCursor) variables.start_cursor = startCursor
|
|
581
|
-
return executeWMexQuery(variables, Types_1.QueryIds.SEARCH, Types_1.XWAPaths.xwa2_newsletters_search)
|
|
582
|
-
},
|
|
583
|
-
|
|
584
|
-
newsletterRecommended: async (limit = 10, numFollowed = null) => {
|
|
585
|
-
const variables = { limit }
|
|
586
|
-
if (numFollowed != null) variables.num_newsletters_followed = numFollowed
|
|
587
|
-
return executeWMexQuery(variables, Types_1.QueryIds.RECOMMENDED, Types_1.XWAPaths.xwa2_newsletters_recommended)
|
|
588
|
-
},
|
|
589
|
-
|
|
590
|
-
newsletterSimilar: async (jid, limit = 10) => {
|
|
591
|
-
return executeWMexQuery(
|
|
592
|
-
{ newsletter_id: jid, limit },
|
|
593
|
-
Types_1.QueryIds.SIMILAR,
|
|
594
|
-
Types_1.XWAPaths.xwa2_newsletters_similar
|
|
595
|
-
)
|
|
596
|
-
},
|
|
597
|
-
|
|
598
|
-
newsletterFollowingList: async (startCursor = null, limit = 20) => {
|
|
599
|
-
const variables = { limit }
|
|
600
|
-
if (startCursor) variables.start_cursor = startCursor
|
|
601
|
-
return executeWMexQuery(variables, Types_1.QueryIds.FOLLOWING_LIST, Types_1.XWAPaths.xwa2_newsletter_following)
|
|
602
|
-
},
|
|
603
|
-
|
|
604
|
-
newsletterInsights: async (jid, period = null) => {
|
|
605
|
-
const variables = { newsletter_id: jid }
|
|
606
|
-
if (period) variables.period = period
|
|
607
|
-
return executeWMexQuery(variables, Types_1.QueryIds.INSIGHTS, Types_1.XWAPaths.xwa2_newsletter_admin_insights)
|
|
608
|
-
},
|
|
609
|
-
|
|
610
|
-
newsletterPollVoterList: async (jid, serverId, option = null, startCursor = null) => {
|
|
611
|
-
const variables = { id: jid, server_id: serverId }
|
|
612
|
-
if (option != null) variables.option = option
|
|
613
|
-
if (startCursor) variables.start_cursor = startCursor
|
|
614
|
-
return executeWMexQuery(
|
|
615
|
-
variables,
|
|
616
|
-
Types_1.QueryIds.POLL_VOTER_LIST,
|
|
617
|
-
Types_1.XWAPaths.xwa2_newsletters_poll_voter_list
|
|
618
|
-
)
|
|
619
|
-
},
|
|
620
|
-
|
|
621
|
-
newsletterReactionSenders: async (jid, serverId, startCursor = null) => {
|
|
622
|
-
const variables = { id: jid, server_id: serverId }
|
|
623
|
-
if (startCursor) variables.start_cursor = startCursor
|
|
624
|
-
return executeWMexQuery(
|
|
625
|
-
variables,
|
|
626
|
-
Types_1.QueryIds.REACTION_SENDERS_LIST,
|
|
627
|
-
Types_1.XWAPaths.xwa2_newsletters_reaction_sender_list
|
|
628
|
-
)
|
|
629
|
-
},
|
|
630
|
-
|
|
631
|
-
newsletterBlockUser: async (jid, userJid) => {
|
|
632
|
-
return executeWMexQuery(
|
|
633
|
-
{ newsletter_id: jid, user_id: userJid },
|
|
634
|
-
Types_1.QueryIds.BLOCK_USER,
|
|
635
|
-
'xwa2_newsletter_block_user'
|
|
636
|
-
)
|
|
637
|
-
},
|
|
638
|
-
|
|
639
|
-
newsletterEnableWamo: async jid => {
|
|
640
|
-
return executeWMexQuery(
|
|
641
|
-
{ newsletter_id: jid },
|
|
642
|
-
Types_1.QueryIds.WAMO_ENABLE_SUB,
|
|
643
|
-
'xwa2_newsletter_wamo_enable_sub'
|
|
644
|
-
)
|
|
645
|
-
},
|
|
646
|
-
|
|
647
|
-
newsletterDisableWamo: async jid => {
|
|
648
|
-
return executeWMexQuery(
|
|
649
|
-
{ newsletter_id: jid },
|
|
650
|
-
Types_1.QueryIds.WAMO_DISABLE_SUB,
|
|
651
|
-
'xwa2_newsletter_wamo_disable_sub'
|
|
652
|
-
)
|
|
653
|
-
},
|
|
654
|
-
|
|
655
|
-
newsletterChangeWamo: async (jid, subConfig) => {
|
|
656
|
-
return executeWMexQuery(
|
|
657
|
-
{ newsletter_id: jid, ...subConfig },
|
|
658
|
-
Types_1.QueryIds.WAMO_CHANGE_SUB,
|
|
659
|
-
'xwa2_newsletter_wamo_change_sub'
|
|
660
|
-
)
|
|
661
|
-
},
|
|
662
|
-
|
|
663
|
-
wamoAfsAgeCollection: async jid =>
|
|
664
|
-
executeWMexQuery(
|
|
665
|
-
{ newsletter_id: jid },
|
|
666
|
-
Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION,
|
|
667
|
-
Types_1.XWAPaths.xwa2_wamo_afs_age_collection
|
|
668
|
-
),
|
|
669
|
-
|
|
670
|
-
wamoAssetCollection: async jid =>
|
|
671
|
-
executeWMexQuery(
|
|
672
|
-
{ newsletter_id: jid },
|
|
673
|
-
Types_1.QueryIds.WAMO_ASSET_COLLECTION,
|
|
674
|
-
Types_1.XWAPaths.xwa2_wamo_asset_collection
|
|
675
|
-
),
|
|
676
|
-
|
|
677
|
-
wamoFetchAdhocNotice: async noticeId =>
|
|
678
|
-
executeWMexQuery(
|
|
679
|
-
{ notice_id: noticeId },
|
|
680
|
-
Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE,
|
|
681
|
-
Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id
|
|
682
|
-
),
|
|
683
|
-
|
|
684
|
-
wamoFetchIdentityToken: async jid =>
|
|
685
|
-
executeWMexQuery(
|
|
686
|
-
{ newsletter_id: jid },
|
|
687
|
-
Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN,
|
|
688
|
-
Types_1.XWAPaths.xwa2_wamo_fetch_identity_token
|
|
689
|
-
),
|
|
690
|
-
|
|
691
|
-
wamoSubComplianceInfo: async jid =>
|
|
692
|
-
executeWMexQuery(
|
|
693
|
-
{ newsletter_id: jid },
|
|
694
|
-
Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO,
|
|
695
|
-
Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info
|
|
696
|
-
),
|
|
697
|
-
|
|
698
|
-
wamoUserIdVersion: async jid =>
|
|
699
|
-
executeWMexQuery(
|
|
700
|
-
{ newsletter_id: jid },
|
|
701
|
-
Types_1.QueryIds.WAMO_USER_ID_VERSION,
|
|
702
|
-
Types_1.XWAPaths.xwa2_wamo_user_id_version
|
|
703
|
-
),
|
|
704
|
-
|
|
705
|
-
wamoSetUserIdVersion: async (jid, version) =>
|
|
706
|
-
executeWMexQuery(
|
|
707
|
-
{ newsletter_id: jid, version },
|
|
708
|
-
Types_1.QueryIds.WAMO_SET_USER_ID_VERSION,
|
|
709
|
-
Types_1.XWAPaths.xwa2_wamo_set_user_id_version
|
|
710
|
-
),
|
|
711
|
-
|
|
712
|
-
newsletterLeave: async jid =>
|
|
713
|
-
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.LEAVE, Types_1.XWAPaths.xwa2_newsletter_leave_v2),
|
|
714
|
-
|
|
715
|
-
newsletterCreateVerified: async (name, description = null) =>
|
|
716
|
-
executeWMexQuery(
|
|
717
|
-
{ input: { name, description } },
|
|
718
|
-
Types_1.QueryIds.CREATE_VERIFIED,
|
|
719
|
-
Types_1.XWAPaths.xwa2_newsletter_create_verified
|
|
720
|
-
),
|
|
721
|
-
|
|
722
|
-
newsletterEnforcements: async jid =>
|
|
723
|
-
executeWMexQuery(
|
|
724
|
-
{ newsletter_id: jid },
|
|
725
|
-
Types_1.QueryIds.ENFORCEMENTS,
|
|
726
|
-
Types_1.XWAPaths.xwa2_newsletter_enforcements
|
|
727
|
-
),
|
|
728
|
-
|
|
729
|
-
newsletterUserReports: async (jid, cursor = null) => {
|
|
730
|
-
const variables = { newsletter_id: jid }
|
|
731
|
-
if (cursor) variables.cursor = cursor
|
|
732
|
-
return executeWMexQuery(variables, Types_1.QueryIds.USER_REPORTS, Types_1.XWAPaths.xwa2_newsletter_user_reports)
|
|
733
|
-
},
|
|
734
|
-
|
|
735
|
-
newsletterCreateReportAppeal: async (jid, reason) =>
|
|
736
|
-
executeWMexQuery(
|
|
737
|
-
{ newsletter_id: jid, reason },
|
|
738
|
-
Types_1.QueryIds.CREATE_REPORT_APPEAL,
|
|
739
|
-
Types_1.XWAPaths.xwa2_newsletter_create_report_appeal
|
|
740
|
-
),
|
|
741
|
-
|
|
742
|
-
newsletterLinkPreviewCheck: async url =>
|
|
743
|
-
executeWMexQuery(
|
|
744
|
-
{ url },
|
|
745
|
-
Types_1.QueryIds.LINK_PREVIEW_CHECK,
|
|
746
|
-
Types_1.XWAPaths.xwa2_newsletter_link_preview_check
|
|
747
|
-
),
|
|
748
|
-
|
|
749
|
-
newsletterUpdateVerification: async (jid, verification) =>
|
|
750
|
-
executeWMexQuery(
|
|
751
|
-
{ newsletter_id: jid, verification },
|
|
752
|
-
Types_1.QueryIds.UPDATE_VERIFICATION,
|
|
753
|
-
Types_1.XWAPaths.xwa2_newsletter_update_verification
|
|
754
|
-
),
|
|
755
|
-
|
|
756
|
-
newsletterLabelPaidPartnership: async (jid, serverId, messageType = 'MESSAGE') =>
|
|
757
|
-
executeWMexQuery(
|
|
758
|
-
{ newsletter_id: jid, server_id: String(serverId), message_type: messageType },
|
|
759
|
-
Types_1.QueryIds.LABEL_PAID_PARTNERSHIP,
|
|
760
|
-
Types_1.XWAPaths.xwa2_newsletter_label_paid_partnership
|
|
761
|
-
),
|
|
762
|
-
|
|
763
|
-
newsletterLogExposures: async events =>
|
|
764
|
-
executeWMexQuery({ events }, Types_1.QueryIds.LOG_EXPOSURES, Types_1.XWAPaths.xwa2_newsletter_log_exposures),
|
|
765
|
-
|
|
766
|
-
newsletterUpdateUserSetting: async (jid, setting) =>
|
|
767
|
-
executeWMexQuery(
|
|
768
|
-
{ newsletter_id: jid, ...setting },
|
|
769
|
-
Types_1.QueryIds.UPDATE_USER_SETTING,
|
|
770
|
-
Types_1.XWAPaths.xwa2_newsletter_update_user_setting
|
|
771
|
-
),
|
|
772
|
-
|
|
773
|
-
newsletterRankingFeatures: async jid =>
|
|
774
|
-
executeWMexQuery(
|
|
775
|
-
{ newsletter_id: jid },
|
|
776
|
-
Types_1.QueryIds.RANKING_FEATURES,
|
|
777
|
-
Types_1.XWAPaths.xwa2_newsletter_ranking_features
|
|
778
|
-
),
|
|
779
|
-
|
|
780
|
-
fetchReachoutTimelock: async () =>
|
|
781
|
-
executeWMexQuery({}, Types_1.QueryIds.REACHOUT_TIMELOCK, Types_1.XWAPaths.xwa2_fetch_account_reachout_timelock),
|
|
782
|
-
|
|
783
|
-
fetchMessageCappingInfo: async () =>
|
|
784
|
-
executeWMexQuery({}, Types_1.QueryIds.MESSAGE_CAPPING_INFO, Types_1.XWAPaths.xwa2_message_capping_info),
|
|
785
|
-
|
|
786
|
-
newsletterQuestionResponseStateUpdate: async (jid, serverId, state) =>
|
|
787
|
-
executeWMexQuery(
|
|
788
|
-
{ newsletter_id: jid, server_id: serverId, state },
|
|
789
|
-
Types_1.QueryIds.QUESTION_RESPONSE_STATE_UPDATE,
|
|
790
|
-
Types_1.XWAPaths.xwa2_newsletter_question_response_state_update
|
|
791
|
-
),
|
|
792
|
-
|
|
793
|
-
newsletterSendViewReceipt: async (jid, serverMessageIds) => {
|
|
794
|
-
const ids = Array.isArray(serverMessageIds) ? serverMessageIds : [serverMessageIds]
|
|
795
|
-
const receiptId = generateMessageTag()
|
|
796
|
-
await query({
|
|
797
|
-
tag: 'receipt',
|
|
798
|
-
attrs: {
|
|
799
|
-
to: jid,
|
|
800
|
-
id: receiptId,
|
|
801
|
-
type: 'view'
|
|
802
|
-
},
|
|
803
|
-
content: [
|
|
804
|
-
{
|
|
805
|
-
tag: 'list',
|
|
806
|
-
attrs: {},
|
|
807
|
-
content: ids.map(id => ({ tag: 'item', attrs: { server_id: String(id) } }))
|
|
808
|
-
}
|
|
809
|
-
]
|
|
810
|
-
})
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
exports.makeNewsletterSocket = makeNewsletterSocket
|