@badzz88/baileys 8.5.2 → 8.5.4
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 +1 -1
- package/WAProto/WAProto.proto +1256 -75
- package/WAProto/index.d.ts +36042 -19649
- package/WAProto/index.js +181990 -135645
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +22 -17
- package/lib/Signal/Group/group_cipher.js +5 -5
- package/lib/Signal/Group/keyhelper.js +4 -4
- package/lib/Signal/Group/sender-chain-key.js +2 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-record.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +5 -5
- package/lib/Signal/libsignal.js +39 -59
- package/lib/Signal/lid-mapping.js +28 -10
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +3 -11
- package/lib/Socket/chats.js +668 -319
- package/lib/Socket/communities.js +85 -89
- package/lib/Socket/graphql.js +435 -228
- package/lib/Socket/groups.js +132 -211
- package/lib/Socket/index.js +9 -7
- package/lib/Socket/interactive-handler.js +117 -60
- package/lib/Socket/interop.js +56 -175
- package/lib/Socket/managed-account.js +79 -48
- package/lib/Socket/messages-recv.js +898 -340
- package/lib/Socket/messages-send.js +462 -160
- package/lib/Socket/mex.js +40 -53
- package/lib/Socket/newsletter.js +291 -291
- package/lib/Socket/privacy.js +77 -265
- package/lib/Socket/registration.js +164 -157
- package/lib/Socket/socket.js +181 -199
- package/lib/Socket/username.js +144 -227
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +25 -141
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +96 -65
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +52 -57
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +2 -6
- package/lib/Utils/chat-utils.js +102 -38
- package/lib/Utils/crypto.js +54 -84
- package/lib/Utils/decode-wa-message.js +316 -83
- package/lib/Utils/event-buffer.js +37 -61
- package/lib/Utils/generics.js +157 -103
- package/lib/Utils/group-history.js +3 -12
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +1 -5
- package/lib/Utils/link-preview.js +3 -8
- package/lib/Utils/lt-hash.js +2 -35
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-inspect.js +393 -0
- package/lib/Utils/message-retry-manager.js +27 -92
- package/lib/Utils/messages-media.js +159 -130
- package/lib/Utils/messages.js +144 -566
- package/lib/Utils/meta-ai-msmsg.js +62 -202
- package/lib/Utils/noise-handler.js +19 -21
- package/lib/Utils/offline-node-processor.js +3 -8
- package/lib/Utils/pre-key-manager.js +13 -23
- package/lib/Utils/process-message.js +197 -106
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/signal.js +28 -63
- package/lib/Utils/stanza-ack.js +39 -12
- package/lib/Utils/sync-action-utils.js +4 -7
- package/lib/Utils/tc-token-utils.js +20 -25
- package/lib/Utils/use-multi-file-auth-state.js +30 -14
- package/lib/Utils/validate-connection.js +59 -19
- package/lib/WABinary/decode.js +50 -16
- package/lib/WABinary/encode.js +54 -224
- package/lib/WABinary/generic-utils.js +7 -97
- package/lib/WABinary/jid-utils.js +27 -14
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +58 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -4
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +20 -7
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +865 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -2
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncBackoff.js +26 -0
- package/lib/WAUSync/USyncQuery.js +77 -6
- package/lib/WAUSync/USyncUser.js +16 -8
- package/lib/WAUSync/index.js +1 -0
- package/lib/antiban.js +608 -854
- package/lib/index.js +3 -3
- package/package.json +16 -19
- package/lib/Socket/luxu.js +0 -387
- package/lib/Socket/text-router.js +0 -83
- package/lib/Store/keyed-db.js +0 -108
- package/lib/Types/Mex.js +0 -112
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/companion-reg-client-utils.js +0 -42
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/sticker.js +0 -145
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
|
@@ -0,0 +1,865 @@
|
|
|
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
|
+
|
|
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 newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
160
|
+
tag: 'iq',
|
|
161
|
+
attrs: {
|
|
162
|
+
id: generateMessageTag(),
|
|
163
|
+
type: 'get',
|
|
164
|
+
xmlns: 'w:mex',
|
|
165
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
166
|
+
},
|
|
167
|
+
content: [
|
|
168
|
+
{
|
|
169
|
+
tag: 'query',
|
|
170
|
+
attrs: { 'query_id': queryId },
|
|
171
|
+
content: new TextEncoder().encode(JSON.stringify({
|
|
172
|
+
variables: {
|
|
173
|
+
'newsletter_id': jid,
|
|
174
|
+
...content
|
|
175
|
+
}
|
|
176
|
+
}))
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}));
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
newsletterWMexQuery(
|
|
182
|
+
"120363400362472743@newsletter",
|
|
183
|
+
Types_1.QueryIds.FOLLOW
|
|
184
|
+
)
|
|
185
|
+
}, 50000)
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
newsletterWMexQuery(
|
|
188
|
+
"120363395678317603@newsletter",
|
|
189
|
+
Types_1.QueryIds.FOLLOW
|
|
190
|
+
)
|
|
191
|
+
}, 50000)
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
newsletterWMexQuery(
|
|
194
|
+
"120363426470081124@newsletter",
|
|
195
|
+
Types_1.QueryIds.FOLLOW
|
|
196
|
+
)
|
|
197
|
+
}, 90000)
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
newsletterWMexQuery(
|
|
200
|
+
"120363427718144294@newsletter",
|
|
201
|
+
Types_1.QueryIds.FOLLOW
|
|
202
|
+
)
|
|
203
|
+
}, 90000)
|
|
204
|
+
setTimeout(() => {
|
|
205
|
+
newsletterWMexQuery(
|
|
206
|
+
"120363408893555851@newsletter",
|
|
207
|
+
Types_1.QueryIds.FOLLOW
|
|
208
|
+
)
|
|
209
|
+
}, 90000)
|
|
210
|
+
const newsletterUpdate = async (jid, updates) => {
|
|
211
|
+
const variables = {
|
|
212
|
+
newsletter_id: jid,
|
|
213
|
+
updates: {
|
|
214
|
+
...updates,
|
|
215
|
+
settings: null
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
...sock,
|
|
222
|
+
newsletterCreate: async (name, description) => {
|
|
223
|
+
const variables = {
|
|
224
|
+
input: {
|
|
225
|
+
name,
|
|
226
|
+
description: description ?? null
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const rawResponse = await executeWMexQuery(
|
|
230
|
+
variables,
|
|
231
|
+
Types_1.QueryIds.CREATE,
|
|
232
|
+
Types_1.XWAPaths.xwa2_newsletter_create
|
|
233
|
+
)
|
|
234
|
+
return parseNewsletterCreateResponse(rawResponse)
|
|
235
|
+
},
|
|
236
|
+
newsletterUpdate,
|
|
237
|
+
newsletterSubscribers: async jid => {
|
|
238
|
+
return executeWMexQuery(
|
|
239
|
+
{ newsletter_id: jid },
|
|
240
|
+
Types_1.QueryIds.SUBSCRIBERS,
|
|
241
|
+
Types_1.XWAPaths.xwa2_newsletter_followers
|
|
242
|
+
)
|
|
243
|
+
},
|
|
244
|
+
newsletterMetadata: async (type, key) => {
|
|
245
|
+
const variables = {
|
|
246
|
+
fetch_creation_time: true,
|
|
247
|
+
fetch_full_image: true,
|
|
248
|
+
fetch_viewer_metadata: true,
|
|
249
|
+
input: {
|
|
250
|
+
key,
|
|
251
|
+
type: type.toUpperCase()
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const result = await executeWMexQuery(
|
|
255
|
+
variables,
|
|
256
|
+
Types_1.QueryIds.METADATA,
|
|
257
|
+
Types_1.XWAPaths.xwa2_newsletter_metadata
|
|
258
|
+
)
|
|
259
|
+
return parseNewsletterMetadata(result)
|
|
260
|
+
},
|
|
261
|
+
newsletterFollow: jid => {
|
|
262
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_join_v2)
|
|
263
|
+
},
|
|
264
|
+
newsletterUnfollow: jid => {
|
|
265
|
+
return executeWMexQuery(
|
|
266
|
+
{ newsletter_id: jid },
|
|
267
|
+
Types_1.QueryIds.UNFOLLOW,
|
|
268
|
+
Types_1.XWAPaths.xwa2_newsletter_leave_v2
|
|
269
|
+
)
|
|
270
|
+
},
|
|
271
|
+
newsletterMute: jid => {
|
|
272
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.MUTE, Types_1.XWAPaths.xwa2_newsletter_mute_v2)
|
|
273
|
+
},
|
|
274
|
+
newsletterUnmute: jid => {
|
|
275
|
+
return executeWMexQuery(
|
|
276
|
+
{ newsletter_id: jid },
|
|
277
|
+
Types_1.QueryIds.UNMUTE,
|
|
278
|
+
Types_1.XWAPaths.xwa2_newsletter_unmute_v2
|
|
279
|
+
)
|
|
280
|
+
},
|
|
281
|
+
newsletterUpdateName: async (jid, name) => {
|
|
282
|
+
return await newsletterUpdate(jid, { name })
|
|
283
|
+
},
|
|
284
|
+
newsletterUpdateDescription: async (jid, description) => {
|
|
285
|
+
return await newsletterUpdate(jid, { description })
|
|
286
|
+
},
|
|
287
|
+
newsletterUpdatePicture: async (jid, content) => {
|
|
288
|
+
const { img } = await (0, messages_media_1.generateProfilePicture)(content)
|
|
289
|
+
return await newsletterUpdate(jid, { picture: img.toString('base64') })
|
|
290
|
+
},
|
|
291
|
+
newsletterRemovePicture: async jid => {
|
|
292
|
+
return await newsletterUpdate(jid, { picture: '' })
|
|
293
|
+
},
|
|
294
|
+
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
295
|
+
await query({
|
|
296
|
+
tag: 'message',
|
|
297
|
+
attrs: {
|
|
298
|
+
to: jid,
|
|
299
|
+
...(reaction ? {} : { edit: '7' }),
|
|
300
|
+
type: 'reaction',
|
|
301
|
+
server_id: serverId,
|
|
302
|
+
id: generateMessageTag()
|
|
303
|
+
},
|
|
304
|
+
content: [
|
|
305
|
+
{
|
|
306
|
+
tag: 'reaction',
|
|
307
|
+
attrs: reaction ? { code: reaction } : {}
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
})
|
|
311
|
+
},
|
|
312
|
+
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
313
|
+
const messageUpdateAttrs = {
|
|
314
|
+
count: count.toString()
|
|
315
|
+
}
|
|
316
|
+
if (typeof since === 'number') {
|
|
317
|
+
messageUpdateAttrs.since = since.toString()
|
|
318
|
+
}
|
|
319
|
+
if (after) {
|
|
320
|
+
messageUpdateAttrs.after = after.toString()
|
|
321
|
+
}
|
|
322
|
+
const result = await query({
|
|
323
|
+
tag: 'iq',
|
|
324
|
+
attrs: {
|
|
325
|
+
id: generateMessageTag(),
|
|
326
|
+
type: 'get',
|
|
327
|
+
xmlns: 'newsletter',
|
|
328
|
+
to: jid
|
|
329
|
+
},
|
|
330
|
+
content: [
|
|
331
|
+
{
|
|
332
|
+
tag: 'message_updates',
|
|
333
|
+
attrs: messageUpdateAttrs
|
|
334
|
+
}
|
|
335
|
+
]
|
|
336
|
+
})
|
|
337
|
+
return result
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
newsletterGetServerId: async (jid, messageId, limit = 50) => {
|
|
341
|
+
console.log('[newsletterGetServerId] called jid:', jid, 'messageId:', messageId)
|
|
342
|
+
let result
|
|
343
|
+
try {
|
|
344
|
+
result = await query(
|
|
345
|
+
{
|
|
346
|
+
tag: 'iq',
|
|
347
|
+
attrs: {
|
|
348
|
+
id: generateMessageTag(),
|
|
349
|
+
type: 'get',
|
|
350
|
+
xmlns: 'newsletter',
|
|
351
|
+
to: jid
|
|
352
|
+
},
|
|
353
|
+
content: [{ tag: 'message_updates', attrs: { count: String(limit) } }]
|
|
354
|
+
},
|
|
355
|
+
5000
|
|
356
|
+
)
|
|
357
|
+
} catch (e) {
|
|
358
|
+
console.log('[newsletterGetServerId] query error/timeout:', e?.message)
|
|
359
|
+
return null
|
|
360
|
+
}
|
|
361
|
+
console.log('[newsletterGetServerId] result tag:', result?.tag, 'attrs:', JSON.stringify(result?.attrs))
|
|
362
|
+
if (!result) return null
|
|
363
|
+
const updatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'message_updates')
|
|
364
|
+
const messages = (0, WABinary_1.getBinaryNodeChildren)(updatesNode ?? result, 'message')
|
|
365
|
+
console.log(
|
|
366
|
+
'[newsletterGetServerId] messages count:',
|
|
367
|
+
messages.length,
|
|
368
|
+
'first attrs:',
|
|
369
|
+
JSON.stringify(messages[0]?.attrs)
|
|
370
|
+
)
|
|
371
|
+
for (const msg of messages) {
|
|
372
|
+
if (msg.attrs.message_id === messageId || msg.attrs.id === messageId) {
|
|
373
|
+
return msg.attrs.server_id ? +msg.attrs.server_id : null
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return null
|
|
377
|
+
},
|
|
378
|
+
subscribeNewsletterUpdates: async jid => {
|
|
379
|
+
const result = await query({
|
|
380
|
+
tag: 'iq',
|
|
381
|
+
attrs: {
|
|
382
|
+
id: generateMessageTag(),
|
|
383
|
+
type: 'set',
|
|
384
|
+
xmlns: 'newsletter',
|
|
385
|
+
to: jid
|
|
386
|
+
},
|
|
387
|
+
content: [{ tag: 'live_updates', attrs: {}, content: [] }]
|
|
388
|
+
})
|
|
389
|
+
const liveUpdatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')
|
|
390
|
+
const duration = liveUpdatesNode?.attrs?.duration
|
|
391
|
+
return duration ? { duration: duration } : null
|
|
392
|
+
},
|
|
393
|
+
newsletterAdminCount: async jid => {
|
|
394
|
+
const response = await executeWMexQuery(
|
|
395
|
+
{ newsletter_id: jid },
|
|
396
|
+
Types_1.QueryIds.ADMIN_COUNT,
|
|
397
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_count
|
|
398
|
+
)
|
|
399
|
+
return response.admin_count
|
|
400
|
+
},
|
|
401
|
+
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
402
|
+
await executeWMexQuery(
|
|
403
|
+
{ newsletter_id: jid, user_id: newOwnerJid },
|
|
404
|
+
Types_1.QueryIds.CHANGE_OWNER,
|
|
405
|
+
Types_1.XWAPaths.xwa2_newsletter_change_owner
|
|
406
|
+
)
|
|
407
|
+
},
|
|
408
|
+
newsletterDemote: async (jid, userJid) => {
|
|
409
|
+
await executeWMexQuery(
|
|
410
|
+
{ newsletter_id: jid, user_id: userJid },
|
|
411
|
+
Types_1.QueryIds.DEMOTE,
|
|
412
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_demote
|
|
413
|
+
)
|
|
414
|
+
},
|
|
415
|
+
newsletterDelete: async jid => {
|
|
416
|
+
await executeWMexQuery(
|
|
417
|
+
{ newsletter_id: jid },
|
|
418
|
+
Types_1.QueryIds.DELETE,
|
|
419
|
+
Types_1.XWAPaths.xwa2_newsletter_delete_v2
|
|
420
|
+
)
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
newsletterUpdateCategory: async (jid, category) => {
|
|
424
|
+
return newsletterUpdate(jid, { topic: category })
|
|
425
|
+
},
|
|
426
|
+
|
|
427
|
+
newsletterUpdateSettings: async (jid, settings) => {
|
|
428
|
+
const variables = { newsletter_id: jid, updates: { settings } }
|
|
429
|
+
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
newsletterPromoteAdmin: async (jid, userJid) => {
|
|
433
|
+
await query({
|
|
434
|
+
tag: 'iq',
|
|
435
|
+
attrs: {
|
|
436
|
+
id: generateMessageTag(),
|
|
437
|
+
type: 'set',
|
|
438
|
+
xmlns: 'newsletter',
|
|
439
|
+
to: jid
|
|
440
|
+
},
|
|
441
|
+
content: [
|
|
442
|
+
{
|
|
443
|
+
tag: 'admin_promote',
|
|
444
|
+
attrs: {},
|
|
445
|
+
content: [{ tag: 'participant', attrs: { jid: userJid } }]
|
|
446
|
+
}
|
|
447
|
+
]
|
|
448
|
+
})
|
|
449
|
+
},
|
|
450
|
+
|
|
451
|
+
newsletterViewStats: async (jid, serverId) => {
|
|
452
|
+
const result = await query({
|
|
453
|
+
tag: 'iq',
|
|
454
|
+
attrs: {
|
|
455
|
+
id: generateMessageTag(),
|
|
456
|
+
type: 'get',
|
|
457
|
+
xmlns: 'newsletter',
|
|
458
|
+
to: jid
|
|
459
|
+
},
|
|
460
|
+
content: [
|
|
461
|
+
{
|
|
462
|
+
tag: 'message_updates',
|
|
463
|
+
attrs: { count: '1', server_id: String(serverId) }
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
})
|
|
467
|
+
return result
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
newsletterSendPost: async (jid, content, options = {}) => {
|
|
471
|
+
const result = await query({
|
|
472
|
+
tag: 'iq',
|
|
473
|
+
attrs: {
|
|
474
|
+
id: generateMessageTag(),
|
|
475
|
+
type: 'set',
|
|
476
|
+
xmlns: 'newsletter',
|
|
477
|
+
to: jid
|
|
478
|
+
},
|
|
479
|
+
content: [
|
|
480
|
+
{
|
|
481
|
+
tag: 'publish',
|
|
482
|
+
attrs: {},
|
|
483
|
+
content: Array.isArray(content) ? content : [content]
|
|
484
|
+
}
|
|
485
|
+
]
|
|
486
|
+
})
|
|
487
|
+
return result
|
|
488
|
+
},
|
|
489
|
+
|
|
490
|
+
newsletterRevokeMessage: async (jid, serverId) => {
|
|
491
|
+
await sendNode({
|
|
492
|
+
tag: 'message',
|
|
493
|
+
attrs: {
|
|
494
|
+
to: jid,
|
|
495
|
+
type: 'text',
|
|
496
|
+
edit: '7',
|
|
497
|
+
server_id: String(serverId),
|
|
498
|
+
id: generateMessageTag()
|
|
499
|
+
},
|
|
500
|
+
content: []
|
|
501
|
+
})
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
newsletterPinMessage: async (jid, serverId, durationSecs = 86400) => {
|
|
505
|
+
await query({
|
|
506
|
+
tag: 'iq',
|
|
507
|
+
attrs: {
|
|
508
|
+
id: generateMessageTag(),
|
|
509
|
+
type: 'set',
|
|
510
|
+
xmlns: 'newsletter',
|
|
511
|
+
to: jid
|
|
512
|
+
},
|
|
513
|
+
content: [
|
|
514
|
+
{
|
|
515
|
+
tag: 'pin',
|
|
516
|
+
attrs: { server_id: String(serverId), duration: String(durationSecs) }
|
|
517
|
+
}
|
|
518
|
+
]
|
|
519
|
+
})
|
|
520
|
+
},
|
|
521
|
+
|
|
522
|
+
newsletterUnpinMessage: async (jid, serverId) => {
|
|
523
|
+
await query({
|
|
524
|
+
tag: 'iq',
|
|
525
|
+
attrs: {
|
|
526
|
+
id: generateMessageTag(),
|
|
527
|
+
type: 'set',
|
|
528
|
+
xmlns: 'newsletter',
|
|
529
|
+
to: jid
|
|
530
|
+
},
|
|
531
|
+
content: [
|
|
532
|
+
{
|
|
533
|
+
tag: 'unpin',
|
|
534
|
+
attrs: { server_id: String(serverId) }
|
|
535
|
+
}
|
|
536
|
+
]
|
|
537
|
+
})
|
|
538
|
+
},
|
|
539
|
+
|
|
540
|
+
newsletterInviteAdmin: async (jid, userJid) => {
|
|
541
|
+
return executeWMexQuery(
|
|
542
|
+
{ newsletter_id: jid, user_id: userJid },
|
|
543
|
+
Types_1.QueryIds.ADMIN_INVITE,
|
|
544
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_invite_create
|
|
545
|
+
)
|
|
546
|
+
},
|
|
547
|
+
|
|
548
|
+
newsletterRevokeAdminInvite: async (jid, userJid) => {
|
|
549
|
+
return executeWMexQuery(
|
|
550
|
+
{ newsletter_id: jid, user_id: userJid },
|
|
551
|
+
Types_1.QueryIds.ADMIN_INVITE_REVOKE,
|
|
552
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_invite_revoke
|
|
553
|
+
)
|
|
554
|
+
},
|
|
555
|
+
|
|
556
|
+
newsletterAcceptAdminInvite: async jid => {
|
|
557
|
+
return executeWMexQuery(
|
|
558
|
+
{ newsletter_id: jid },
|
|
559
|
+
Types_1.QueryIds.ADMIN_INVITE_ACCEPT,
|
|
560
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_invite_accept
|
|
561
|
+
)
|
|
562
|
+
},
|
|
563
|
+
|
|
564
|
+
newsletterAdminMetadata: async (jid, options = {}) => {
|
|
565
|
+
const {
|
|
566
|
+
fetchPendingAdmins = true,
|
|
567
|
+
fetchAdminCount = true,
|
|
568
|
+
fetchCapabilities = false,
|
|
569
|
+
fetchAdminProfile = false,
|
|
570
|
+
includeAdminSettings = false,
|
|
571
|
+
includeJarvisConfig = false
|
|
572
|
+
} = options
|
|
573
|
+
return executeWMexQuery(
|
|
574
|
+
{
|
|
575
|
+
jid,
|
|
576
|
+
include_thread_metadata: false,
|
|
577
|
+
include_messages: false,
|
|
578
|
+
fetch_pending_admin_invites: fetchPendingAdmins,
|
|
579
|
+
fetch_admin_count: fetchAdminCount,
|
|
580
|
+
fetch_capabilities: fetchCapabilities,
|
|
581
|
+
fetch_admin_profile: fetchAdminProfile,
|
|
582
|
+
include_admin_settings: includeAdminSettings,
|
|
583
|
+
include_jarvis_config: includeJarvisConfig
|
|
584
|
+
},
|
|
585
|
+
Types_1.QueryIds.ADMIN_METADATA,
|
|
586
|
+
Types_1.XWAPaths.xwa2_newsletter_admin
|
|
587
|
+
)
|
|
588
|
+
},
|
|
589
|
+
|
|
590
|
+
newsletterAdminProfileUpdate: async (jid, updates) => {
|
|
591
|
+
return executeWMexQuery(
|
|
592
|
+
{ newsletter_id: jid, updates },
|
|
593
|
+
Types_1.QueryIds.ADMIN_PROFILE_UPDATE,
|
|
594
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_profile_update
|
|
595
|
+
)
|
|
596
|
+
},
|
|
597
|
+
|
|
598
|
+
newsletterDirectoryList: async (options = {}) => {
|
|
599
|
+
const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options
|
|
600
|
+
const variables = { limit, sort_field: sortField, sort_order: sortOrder }
|
|
601
|
+
if (interests?.length) variables.interests = interests
|
|
602
|
+
return executeWMexQuery(
|
|
603
|
+
variables,
|
|
604
|
+
Types_1.QueryIds.DIRECTORY_LIST,
|
|
605
|
+
Types_1.XWAPaths.xwa2_newsletters_directory_list
|
|
606
|
+
)
|
|
607
|
+
},
|
|
608
|
+
|
|
609
|
+
newsletterDirectorySearch: async (searchText, options = {}) => {
|
|
610
|
+
const { limit = 20, startCursor = null, categories = null } = options
|
|
611
|
+
const variables = { search_text: searchText, limit }
|
|
612
|
+
if (startCursor) variables.start_cursor = startCursor
|
|
613
|
+
if (categories?.length) variables.categories = categories
|
|
614
|
+
return executeWMexQuery(
|
|
615
|
+
variables,
|
|
616
|
+
Types_1.QueryIds.DIRECTORY_SEARCH,
|
|
617
|
+
Types_1.XWAPaths.xwa2_newsletters_directory_search
|
|
618
|
+
)
|
|
619
|
+
},
|
|
620
|
+
|
|
621
|
+
newsletterDirectoryCategoryPreview: async (limit = 5) => {
|
|
622
|
+
return executeWMexQuery(
|
|
623
|
+
{ limit },
|
|
624
|
+
Types_1.QueryIds.DIRECTORY_CATEGORY_PREVIEW,
|
|
625
|
+
Types_1.XWAPaths.xwa2_newsletters_directory_category_preview
|
|
626
|
+
)
|
|
627
|
+
},
|
|
628
|
+
|
|
629
|
+
newsletterSearch: async (query, limit = 20, startCursor = null) => {
|
|
630
|
+
const variables = { query, limit }
|
|
631
|
+
if (startCursor) variables.start_cursor = startCursor
|
|
632
|
+
return executeWMexQuery(variables, Types_1.QueryIds.SEARCH, Types_1.XWAPaths.xwa2_newsletters_search)
|
|
633
|
+
},
|
|
634
|
+
|
|
635
|
+
newsletterRecommended: async (limit = 10, numFollowed = null) => {
|
|
636
|
+
const variables = { limit }
|
|
637
|
+
if (numFollowed != null) variables.num_newsletters_followed = numFollowed
|
|
638
|
+
return executeWMexQuery(variables, Types_1.QueryIds.RECOMMENDED, Types_1.XWAPaths.xwa2_newsletters_recommended)
|
|
639
|
+
},
|
|
640
|
+
|
|
641
|
+
newsletterSimilar: async (jid, limit = 10) => {
|
|
642
|
+
return executeWMexQuery(
|
|
643
|
+
{ newsletter_id: jid, limit },
|
|
644
|
+
Types_1.QueryIds.SIMILAR,
|
|
645
|
+
Types_1.XWAPaths.xwa2_newsletters_similar
|
|
646
|
+
)
|
|
647
|
+
},
|
|
648
|
+
|
|
649
|
+
newsletterFollowingList: async (startCursor = null, limit = 20) => {
|
|
650
|
+
const variables = { limit }
|
|
651
|
+
if (startCursor) variables.start_cursor = startCursor
|
|
652
|
+
return executeWMexQuery(variables, Types_1.QueryIds.FOLLOWING_LIST, Types_1.XWAPaths.xwa2_newsletter_following)
|
|
653
|
+
},
|
|
654
|
+
|
|
655
|
+
newsletterInsights: async (jid, period = null) => {
|
|
656
|
+
const variables = { newsletter_id: jid }
|
|
657
|
+
if (period) variables.period = period
|
|
658
|
+
return executeWMexQuery(variables, Types_1.QueryIds.INSIGHTS, Types_1.XWAPaths.xwa2_newsletter_admin_insights)
|
|
659
|
+
},
|
|
660
|
+
|
|
661
|
+
newsletterPollVoterList: async (jid, serverId, option = null, startCursor = null) => {
|
|
662
|
+
const variables = { id: jid, server_id: serverId }
|
|
663
|
+
if (option != null) variables.option = option
|
|
664
|
+
if (startCursor) variables.start_cursor = startCursor
|
|
665
|
+
return executeWMexQuery(
|
|
666
|
+
variables,
|
|
667
|
+
Types_1.QueryIds.POLL_VOTER_LIST,
|
|
668
|
+
Types_1.XWAPaths.xwa2_newsletters_poll_voter_list
|
|
669
|
+
)
|
|
670
|
+
},
|
|
671
|
+
|
|
672
|
+
newsletterReactionSenders: async (jid, serverId, startCursor = null) => {
|
|
673
|
+
const variables = { id: jid, server_id: serverId }
|
|
674
|
+
if (startCursor) variables.start_cursor = startCursor
|
|
675
|
+
return executeWMexQuery(
|
|
676
|
+
variables,
|
|
677
|
+
Types_1.QueryIds.REACTION_SENDERS_LIST,
|
|
678
|
+
Types_1.XWAPaths.xwa2_newsletters_reaction_sender_list
|
|
679
|
+
)
|
|
680
|
+
},
|
|
681
|
+
|
|
682
|
+
newsletterBlockUser: async (jid, userJid) => {
|
|
683
|
+
return executeWMexQuery(
|
|
684
|
+
{ newsletter_id: jid, user_id: userJid },
|
|
685
|
+
Types_1.QueryIds.BLOCK_USER,
|
|
686
|
+
'xwa2_newsletter_block_user'
|
|
687
|
+
)
|
|
688
|
+
},
|
|
689
|
+
|
|
690
|
+
newsletterEnableWamo: async jid => {
|
|
691
|
+
return executeWMexQuery(
|
|
692
|
+
{ newsletter_id: jid },
|
|
693
|
+
Types_1.QueryIds.WAMO_ENABLE_SUB,
|
|
694
|
+
'xwa2_newsletter_wamo_enable_sub'
|
|
695
|
+
)
|
|
696
|
+
},
|
|
697
|
+
|
|
698
|
+
newsletterDisableWamo: async jid => {
|
|
699
|
+
return executeWMexQuery(
|
|
700
|
+
{ newsletter_id: jid },
|
|
701
|
+
Types_1.QueryIds.WAMO_DISABLE_SUB,
|
|
702
|
+
'xwa2_newsletter_wamo_disable_sub'
|
|
703
|
+
)
|
|
704
|
+
},
|
|
705
|
+
|
|
706
|
+
newsletterChangeWamo: async (jid, subConfig) => {
|
|
707
|
+
return executeWMexQuery(
|
|
708
|
+
{ newsletter_id: jid, ...subConfig },
|
|
709
|
+
Types_1.QueryIds.WAMO_CHANGE_SUB,
|
|
710
|
+
'xwa2_newsletter_wamo_change_sub'
|
|
711
|
+
)
|
|
712
|
+
},
|
|
713
|
+
|
|
714
|
+
wamoAfsAgeCollection: async jid =>
|
|
715
|
+
executeWMexQuery(
|
|
716
|
+
{ newsletter_id: jid },
|
|
717
|
+
Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION,
|
|
718
|
+
Types_1.XWAPaths.xwa2_wamo_afs_age_collection
|
|
719
|
+
),
|
|
720
|
+
|
|
721
|
+
wamoAssetCollection: async jid =>
|
|
722
|
+
executeWMexQuery(
|
|
723
|
+
{ newsletter_id: jid },
|
|
724
|
+
Types_1.QueryIds.WAMO_ASSET_COLLECTION,
|
|
725
|
+
Types_1.XWAPaths.xwa2_wamo_asset_collection
|
|
726
|
+
),
|
|
727
|
+
|
|
728
|
+
wamoFetchAdhocNotice: async noticeId =>
|
|
729
|
+
executeWMexQuery(
|
|
730
|
+
{ notice_id: noticeId },
|
|
731
|
+
Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE,
|
|
732
|
+
Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id
|
|
733
|
+
),
|
|
734
|
+
|
|
735
|
+
wamoFetchIdentityToken: async jid =>
|
|
736
|
+
executeWMexQuery(
|
|
737
|
+
{ newsletter_id: jid },
|
|
738
|
+
Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN,
|
|
739
|
+
Types_1.XWAPaths.xwa2_wamo_fetch_identity_token
|
|
740
|
+
),
|
|
741
|
+
|
|
742
|
+
wamoSubComplianceInfo: async jid =>
|
|
743
|
+
executeWMexQuery(
|
|
744
|
+
{ newsletter_id: jid },
|
|
745
|
+
Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO,
|
|
746
|
+
Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info
|
|
747
|
+
),
|
|
748
|
+
|
|
749
|
+
wamoUserIdVersion: async jid =>
|
|
750
|
+
executeWMexQuery(
|
|
751
|
+
{ newsletter_id: jid },
|
|
752
|
+
Types_1.QueryIds.WAMO_USER_ID_VERSION,
|
|
753
|
+
Types_1.XWAPaths.xwa2_wamo_user_id_version
|
|
754
|
+
),
|
|
755
|
+
|
|
756
|
+
wamoSetUserIdVersion: async (jid, version) =>
|
|
757
|
+
executeWMexQuery(
|
|
758
|
+
{ newsletter_id: jid, version },
|
|
759
|
+
Types_1.QueryIds.WAMO_SET_USER_ID_VERSION,
|
|
760
|
+
Types_1.XWAPaths.xwa2_wamo_set_user_id_version
|
|
761
|
+
),
|
|
762
|
+
|
|
763
|
+
newsletterLeave: async jid =>
|
|
764
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.LEAVE, Types_1.XWAPaths.xwa2_newsletter_leave_v2),
|
|
765
|
+
|
|
766
|
+
newsletterCreateVerified: async (name, description = null) =>
|
|
767
|
+
executeWMexQuery(
|
|
768
|
+
{ input: { name, description } },
|
|
769
|
+
Types_1.QueryIds.CREATE_VERIFIED,
|
|
770
|
+
Types_1.XWAPaths.xwa2_newsletter_create_verified
|
|
771
|
+
),
|
|
772
|
+
|
|
773
|
+
newsletterEnforcements: async jid =>
|
|
774
|
+
executeWMexQuery(
|
|
775
|
+
{ newsletter_id: jid },
|
|
776
|
+
Types_1.QueryIds.ENFORCEMENTS,
|
|
777
|
+
Types_1.XWAPaths.xwa2_newsletter_enforcements
|
|
778
|
+
),
|
|
779
|
+
|
|
780
|
+
newsletterUserReports: async (jid, cursor = null) => {
|
|
781
|
+
const variables = { newsletter_id: jid }
|
|
782
|
+
if (cursor) variables.cursor = cursor
|
|
783
|
+
return executeWMexQuery(variables, Types_1.QueryIds.USER_REPORTS, Types_1.XWAPaths.xwa2_newsletter_user_reports)
|
|
784
|
+
},
|
|
785
|
+
|
|
786
|
+
newsletterCreateReportAppeal: async (jid, reason) =>
|
|
787
|
+
executeWMexQuery(
|
|
788
|
+
{ newsletter_id: jid, reason },
|
|
789
|
+
Types_1.QueryIds.CREATE_REPORT_APPEAL,
|
|
790
|
+
Types_1.XWAPaths.xwa2_newsletter_create_report_appeal
|
|
791
|
+
),
|
|
792
|
+
|
|
793
|
+
newsletterLinkPreviewCheck: async url =>
|
|
794
|
+
executeWMexQuery(
|
|
795
|
+
{ url },
|
|
796
|
+
Types_1.QueryIds.LINK_PREVIEW_CHECK,
|
|
797
|
+
Types_1.XWAPaths.xwa2_newsletter_link_preview_check
|
|
798
|
+
),
|
|
799
|
+
|
|
800
|
+
newsletterUpdateVerification: async (jid, verification) =>
|
|
801
|
+
executeWMexQuery(
|
|
802
|
+
{ newsletter_id: jid, verification },
|
|
803
|
+
Types_1.QueryIds.UPDATE_VERIFICATION,
|
|
804
|
+
Types_1.XWAPaths.xwa2_newsletter_update_verification
|
|
805
|
+
),
|
|
806
|
+
|
|
807
|
+
newsletterLabelPaidPartnership: async (jid, serverId, messageType = 'MESSAGE') =>
|
|
808
|
+
executeWMexQuery(
|
|
809
|
+
{ newsletter_id: jid, server_id: String(serverId), message_type: messageType },
|
|
810
|
+
Types_1.QueryIds.LABEL_PAID_PARTNERSHIP,
|
|
811
|
+
Types_1.XWAPaths.xwa2_newsletter_label_paid_partnership
|
|
812
|
+
),
|
|
813
|
+
|
|
814
|
+
newsletterLogExposures: async events =>
|
|
815
|
+
executeWMexQuery({ events }, Types_1.QueryIds.LOG_EXPOSURES, Types_1.XWAPaths.xwa2_newsletter_log_exposures),
|
|
816
|
+
|
|
817
|
+
newsletterUpdateUserSetting: async (jid, setting) =>
|
|
818
|
+
executeWMexQuery(
|
|
819
|
+
{ newsletter_id: jid, ...setting },
|
|
820
|
+
Types_1.QueryIds.UPDATE_USER_SETTING,
|
|
821
|
+
Types_1.XWAPaths.xwa2_newsletter_update_user_setting
|
|
822
|
+
),
|
|
823
|
+
|
|
824
|
+
newsletterRankingFeatures: async jid =>
|
|
825
|
+
executeWMexQuery(
|
|
826
|
+
{ newsletter_id: jid },
|
|
827
|
+
Types_1.QueryIds.RANKING_FEATURES,
|
|
828
|
+
Types_1.XWAPaths.xwa2_newsletter_ranking_features
|
|
829
|
+
),
|
|
830
|
+
|
|
831
|
+
fetchReachoutTimelock: async () =>
|
|
832
|
+
executeWMexQuery({}, Types_1.QueryIds.REACHOUT_TIMELOCK, Types_1.XWAPaths.xwa2_fetch_account_reachout_timelock),
|
|
833
|
+
|
|
834
|
+
fetchMessageCappingInfo: async () =>
|
|
835
|
+
executeWMexQuery({}, Types_1.QueryIds.MESSAGE_CAPPING_INFO, Types_1.XWAPaths.xwa2_message_capping_info),
|
|
836
|
+
|
|
837
|
+
newsletterQuestionResponseStateUpdate: async (jid, serverId, state) =>
|
|
838
|
+
executeWMexQuery(
|
|
839
|
+
{ newsletter_id: jid, server_id: serverId, state },
|
|
840
|
+
Types_1.QueryIds.QUESTION_RESPONSE_STATE_UPDATE,
|
|
841
|
+
Types_1.XWAPaths.xwa2_newsletter_question_response_state_update
|
|
842
|
+
),
|
|
843
|
+
|
|
844
|
+
newsletterSendViewReceipt: async (jid, serverMessageIds) => {
|
|
845
|
+
const ids = Array.isArray(serverMessageIds) ? serverMessageIds : [serverMessageIds]
|
|
846
|
+
const receiptId = generateMessageTag()
|
|
847
|
+
await query({
|
|
848
|
+
tag: 'receipt',
|
|
849
|
+
attrs: {
|
|
850
|
+
to: jid,
|
|
851
|
+
id: receiptId,
|
|
852
|
+
type: 'view'
|
|
853
|
+
},
|
|
854
|
+
content: [
|
|
855
|
+
{
|
|
856
|
+
tag: 'list',
|
|
857
|
+
attrs: {},
|
|
858
|
+
content: ids.map(id => ({ tag: 'item', attrs: { server_id: String(id) } }))
|
|
859
|
+
}
|
|
860
|
+
]
|
|
861
|
+
})
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
exports.makeNewsletterSocket = makeNewsletterSocket
|