@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
package/lib/Socket/newsletter.js
CHANGED
|
@@ -7,9 +7,113 @@ const WABinary_1 = require('../WABinary')
|
|
|
7
7
|
const groups_1 = require('./groups')
|
|
8
8
|
const aigroups_1 = require('./aigroups')
|
|
9
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
|
+
|
|
10
110
|
const parseNewsletterCreateResponse = response => {
|
|
11
111
|
const { id, thread_metadata: thread, viewer_metadata: viewer } = response
|
|
12
|
-
|
|
112
|
+
const dsaCountries = mergeDsaCountries(
|
|
113
|
+
thread.dsa_eligibility_countries ?? null,
|
|
114
|
+
thread.dsa_eligible_countries ?? null
|
|
115
|
+
)
|
|
116
|
+
const base = {
|
|
13
117
|
id: id,
|
|
14
118
|
owner: undefined,
|
|
15
119
|
name: thread.name.text,
|
|
@@ -22,62 +126,36 @@ const parseNewsletterCreateResponse = response => {
|
|
|
22
126
|
id: thread.picture.id,
|
|
23
127
|
directPath: thread.picture.direct_path
|
|
24
128
|
},
|
|
25
|
-
mute_state: viewer.mute
|
|
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)
|
|
26
138
|
}
|
|
139
|
+
return base
|
|
27
140
|
}
|
|
28
141
|
const parseNewsletterMetadata = result => {
|
|
29
142
|
if (typeof result !== 'object' || result === null) {
|
|
30
143
|
return null
|
|
31
144
|
}
|
|
32
145
|
if ('id' in result && typeof result.id === 'string') {
|
|
33
|
-
return result
|
|
146
|
+
return enrichNewsletterMetadata(result)
|
|
34
147
|
}
|
|
35
148
|
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
36
|
-
return result.result
|
|
149
|
+
return enrichNewsletterMetadata(result.result)
|
|
37
150
|
}
|
|
38
151
|
return null
|
|
39
152
|
}
|
|
40
153
|
const makeNewsletterSocket = config => {
|
|
41
154
|
const sock = (0, aigroups_1.makeAIGroupsSocket)(config)
|
|
42
|
-
const
|
|
43
|
-
const { query, generateMessageTag } = sock
|
|
155
|
+
const { query, generateMessageTag, sendNode } = sock
|
|
44
156
|
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
45
157
|
return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag)
|
|
46
158
|
}
|
|
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
|
-
|
|
69
|
-
setTimeout(() => {
|
|
70
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzNDAwMzYyNDcyNzQzQG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW)
|
|
71
|
-
}, 90000)
|
|
72
|
-
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzNDI2NDcwMDgxMTI0QG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW)
|
|
75
|
-
}, 90000)
|
|
76
|
-
|
|
77
|
-
setTimeout(() => {
|
|
78
|
-
newsletterWMexQuery(Buffer.from("MTIwMzYzNDA4ODkzNTU1ODUxQG5ld3NsZXR0ZXI=", "base64").toString(), Types_1.QueryIds.FOLLOW)
|
|
79
|
-
}, 90000)
|
|
80
|
-
|
|
81
159
|
const newsletterUpdate = async (jid, updates) => {
|
|
82
160
|
const variables = {
|
|
83
161
|
newsletter_id: jid,
|
|
@@ -109,7 +187,7 @@ const makeNewsletterSocket = config => {
|
|
|
109
187
|
return executeWMexQuery(
|
|
110
188
|
{ newsletter_id: jid },
|
|
111
189
|
Types_1.QueryIds.SUBSCRIBERS,
|
|
112
|
-
Types_1.XWAPaths.
|
|
190
|
+
Types_1.XWAPaths.xwa2_newsletter_followers
|
|
113
191
|
)
|
|
114
192
|
},
|
|
115
193
|
newsletterMetadata: async (type, key) => {
|
|
@@ -130,13 +208,13 @@ const makeNewsletterSocket = config => {
|
|
|
130
208
|
return parseNewsletterMetadata(result)
|
|
131
209
|
},
|
|
132
210
|
newsletterFollow: jid => {
|
|
133
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.
|
|
211
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_join_v2)
|
|
134
212
|
},
|
|
135
213
|
newsletterUnfollow: jid => {
|
|
136
214
|
return executeWMexQuery(
|
|
137
215
|
{ newsletter_id: jid },
|
|
138
216
|
Types_1.QueryIds.UNFOLLOW,
|
|
139
|
-
Types_1.XWAPaths.
|
|
217
|
+
Types_1.XWAPaths.xwa2_newsletter_leave_v2
|
|
140
218
|
)
|
|
141
219
|
},
|
|
142
220
|
newsletterMute: jid => {
|
|
@@ -207,6 +285,45 @@ const makeNewsletterSocket = config => {
|
|
|
207
285
|
})
|
|
208
286
|
return result
|
|
209
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
|
+
},
|
|
210
327
|
subscribeNewsletterUpdates: async jid => {
|
|
211
328
|
const result = await query({
|
|
212
329
|
tag: 'iq',
|
|
@@ -241,7 +358,7 @@ const makeNewsletterSocket = config => {
|
|
|
241
358
|
await executeWMexQuery(
|
|
242
359
|
{ newsletter_id: jid, user_id: userJid },
|
|
243
360
|
Types_1.QueryIds.DEMOTE,
|
|
244
|
-
Types_1.XWAPaths.
|
|
361
|
+
Types_1.XWAPaths.xwa2_newsletter_admin_demote
|
|
245
362
|
)
|
|
246
363
|
},
|
|
247
364
|
newsletterDelete: async jid => {
|
|
@@ -251,22 +368,16 @@ const makeNewsletterSocket = config => {
|
|
|
251
368
|
Types_1.XWAPaths.xwa2_newsletter_delete_v2
|
|
252
369
|
)
|
|
253
370
|
},
|
|
254
|
-
|
|
255
|
-
* Update newsletter category/topic
|
|
256
|
-
*/
|
|
371
|
+
|
|
257
372
|
newsletterUpdateCategory: async (jid, category) => {
|
|
258
373
|
return newsletterUpdate(jid, { topic: category })
|
|
259
374
|
},
|
|
260
|
-
|
|
261
|
-
* Update newsletter invite codes / settings
|
|
262
|
-
*/
|
|
375
|
+
|
|
263
376
|
newsletterUpdateSettings: async (jid, settings) => {
|
|
264
377
|
const variables = { newsletter_id: jid, updates: { settings } }
|
|
265
378
|
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
|
|
266
379
|
},
|
|
267
|
-
|
|
268
|
-
* Promote a subscriber to admin
|
|
269
|
-
*/
|
|
380
|
+
|
|
270
381
|
newsletterPromoteAdmin: async (jid, userJid) => {
|
|
271
382
|
await query({
|
|
272
383
|
tag: 'iq',
|
|
@@ -285,9 +396,7 @@ const makeNewsletterSocket = config => {
|
|
|
285
396
|
]
|
|
286
397
|
})
|
|
287
398
|
},
|
|
288
|
-
|
|
289
|
-
* Get newsletter view/reach statistics
|
|
290
|
-
*/
|
|
399
|
+
|
|
291
400
|
newsletterViewStats: async (jid, serverId) => {
|
|
292
401
|
const result = await query({
|
|
293
402
|
tag: 'iq',
|
|
@@ -306,9 +415,7 @@ const makeNewsletterSocket = config => {
|
|
|
306
415
|
})
|
|
307
416
|
return result
|
|
308
417
|
},
|
|
309
|
-
|
|
310
|
-
* Send a newsletter post via IQ (alternative to sendMessage for newsletters)
|
|
311
|
-
*/
|
|
418
|
+
|
|
312
419
|
newsletterSendPost: async (jid, content, options = {}) => {
|
|
313
420
|
const result = await query({
|
|
314
421
|
tag: 'iq',
|
|
@@ -328,9 +435,21 @@ const makeNewsletterSocket = config => {
|
|
|
328
435
|
})
|
|
329
436
|
return result
|
|
330
437
|
},
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
+
|
|
334
453
|
newsletterPinMessage: async (jid, serverId, durationSecs = 86400) => {
|
|
335
454
|
await query({
|
|
336
455
|
tag: 'iq',
|
|
@@ -348,9 +467,7 @@ const makeNewsletterSocket = config => {
|
|
|
348
467
|
]
|
|
349
468
|
})
|
|
350
469
|
},
|
|
351
|
-
|
|
352
|
-
* Unpin a newsletter message
|
|
353
|
-
*/
|
|
470
|
+
|
|
354
471
|
newsletterUnpinMessage: async (jid, serverId) => {
|
|
355
472
|
await query({
|
|
356
473
|
tag: 'iq',
|
|
@@ -368,12 +485,7 @@ const makeNewsletterSocket = config => {
|
|
|
368
485
|
]
|
|
369
486
|
})
|
|
370
487
|
},
|
|
371
|
-
|
|
372
|
-
* Invite a user to become an admin of a newsletter.
|
|
373
|
-
*
|
|
374
|
-
* @param {string} jid - Newsletter JID
|
|
375
|
-
* @param {string} userJid - JID of the user to invite
|
|
376
|
-
*/
|
|
488
|
+
|
|
377
489
|
newsletterInviteAdmin: async (jid, userJid) => {
|
|
378
490
|
return executeWMexQuery(
|
|
379
491
|
{ newsletter_id: jid, user_id: userJid },
|
|
@@ -381,12 +493,7 @@ const makeNewsletterSocket = config => {
|
|
|
381
493
|
Types_1.XWAPaths.xwa2_newsletter_admin_invite_create
|
|
382
494
|
)
|
|
383
495
|
},
|
|
384
|
-
|
|
385
|
-
* Revoke a pending admin invite for a newsletter.
|
|
386
|
-
*
|
|
387
|
-
* @param {string} jid - Newsletter JID
|
|
388
|
-
* @param {string} userJid - JID of the invited user to revoke
|
|
389
|
-
*/
|
|
496
|
+
|
|
390
497
|
newsletterRevokeAdminInvite: async (jid, userJid) => {
|
|
391
498
|
return executeWMexQuery(
|
|
392
499
|
{ newsletter_id: jid, user_id: userJid },
|
|
@@ -394,11 +501,7 @@ const makeNewsletterSocket = config => {
|
|
|
394
501
|
Types_1.XWAPaths.xwa2_newsletter_admin_invite_revoke
|
|
395
502
|
)
|
|
396
503
|
},
|
|
397
|
-
|
|
398
|
-
* Accept an admin invite to a newsletter (called by the invitee).
|
|
399
|
-
*
|
|
400
|
-
* @param {string} jid - Newsletter JID
|
|
401
|
-
*/
|
|
504
|
+
|
|
402
505
|
newsletterAcceptAdminInvite: async jid => {
|
|
403
506
|
return executeWMexQuery(
|
|
404
507
|
{ newsletter_id: jid },
|
|
@@ -406,18 +509,7 @@ const makeNewsletterSocket = config => {
|
|
|
406
509
|
Types_1.XWAPaths.xwa2_newsletter_admin_invite_accept
|
|
407
510
|
)
|
|
408
511
|
},
|
|
409
|
-
|
|
410
|
-
* Fetch admin-side metadata for a newsletter.
|
|
411
|
-
*
|
|
412
|
-
* @param {string} jid - Newsletter JID
|
|
413
|
-
* @param {object} options
|
|
414
|
-
* @param {boolean} [options.fetchPendingAdmins=true]
|
|
415
|
-
* @param {boolean} [options.fetchAdminCount=true]
|
|
416
|
-
* @param {boolean} [options.fetchCapabilities=false]
|
|
417
|
-
* @param {boolean} [options.fetchAdminProfile=false]
|
|
418
|
-
* @param {boolean} [options.includeAdminSettings=false]
|
|
419
|
-
* @param {boolean} [options.includeJarvisConfig=false]
|
|
420
|
-
*/
|
|
512
|
+
|
|
421
513
|
newsletterAdminMetadata: async (jid, options = {}) => {
|
|
422
514
|
const {
|
|
423
515
|
fetchPendingAdmins = true,
|
|
@@ -443,12 +535,7 @@ const makeNewsletterSocket = config => {
|
|
|
443
535
|
Types_1.XWAPaths.xwa2_newsletter_admin
|
|
444
536
|
)
|
|
445
537
|
},
|
|
446
|
-
|
|
447
|
-
* Update admin profile fields for a newsletter (e.g. contact info, links).
|
|
448
|
-
*
|
|
449
|
-
* @param {string} jid - Newsletter JID
|
|
450
|
-
* @param {object} updates - Admin profile fields to update
|
|
451
|
-
*/
|
|
538
|
+
|
|
452
539
|
newsletterAdminProfileUpdate: async (jid, updates) => {
|
|
453
540
|
return executeWMexQuery(
|
|
454
541
|
{ newsletter_id: jid, updates },
|
|
@@ -456,30 +543,18 @@ const makeNewsletterSocket = config => {
|
|
|
456
543
|
Types_1.XWAPaths.xwa2_newsletter_admin_profile_update
|
|
457
544
|
)
|
|
458
545
|
},
|
|
459
|
-
|
|
460
|
-
* Browse the newsletter directory by category.
|
|
461
|
-
*
|
|
462
|
-
* @param {object} options
|
|
463
|
-
* @param {number} [options.limit=20]
|
|
464
|
-
* @param {string[]} [options.interests] - Category filters
|
|
465
|
-
* @param {string} [options.sortField='SUBSCRIBER_COUNT']
|
|
466
|
-
* @param {string} [options.sortOrder='DESC']
|
|
467
|
-
*/
|
|
546
|
+
|
|
468
547
|
newsletterDirectoryList: async (options = {}) => {
|
|
469
548
|
const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options
|
|
470
549
|
const variables = { limit, sort_field: sortField, sort_order: sortOrder }
|
|
471
550
|
if (interests?.length) variables.interests = interests
|
|
472
|
-
return executeWMexQuery(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
* @param {number} [options.limit=20]
|
|
480
|
-
* @param {string} [options.startCursor] - Pagination cursor
|
|
481
|
-
* @param {string[]} [options.categories] - Category filters
|
|
482
|
-
*/
|
|
551
|
+
return executeWMexQuery(
|
|
552
|
+
variables,
|
|
553
|
+
Types_1.QueryIds.DIRECTORY_LIST,
|
|
554
|
+
Types_1.XWAPaths.xwa2_newsletters_directory_list
|
|
555
|
+
)
|
|
556
|
+
},
|
|
557
|
+
|
|
483
558
|
newsletterDirectorySearch: async (searchText, options = {}) => {
|
|
484
559
|
const { limit = 20, startCursor = null, categories = null } = options
|
|
485
560
|
const variables = { search_text: searchText, limit }
|
|
@@ -491,11 +566,7 @@ const makeNewsletterSocket = config => {
|
|
|
491
566
|
Types_1.XWAPaths.xwa2_newsletters_directory_search
|
|
492
567
|
)
|
|
493
568
|
},
|
|
494
|
-
|
|
495
|
-
* Fetch a preview of newsletters grouped by directory category.
|
|
496
|
-
*
|
|
497
|
-
* @param {number} [limit=5] - Newsletters per category
|
|
498
|
-
*/
|
|
569
|
+
|
|
499
570
|
newsletterDirectoryCategoryPreview: async (limit = 5) => {
|
|
500
571
|
return executeWMexQuery(
|
|
501
572
|
{ limit },
|
|
@@ -503,35 +574,19 @@ const makeNewsletterSocket = config => {
|
|
|
503
574
|
Types_1.XWAPaths.xwa2_newsletters_directory_category_preview
|
|
504
575
|
)
|
|
505
576
|
},
|
|
506
|
-
|
|
507
|
-
* Search for newsletters by text query.
|
|
508
|
-
*
|
|
509
|
-
* @param {string} query - Search string
|
|
510
|
-
* @param {number} [limit=20]
|
|
511
|
-
* @param {string} [startCursor] - Pagination cursor
|
|
512
|
-
*/
|
|
577
|
+
|
|
513
578
|
newsletterSearch: async (query, limit = 20, startCursor = null) => {
|
|
514
579
|
const variables = { query, limit }
|
|
515
580
|
if (startCursor) variables.start_cursor = startCursor
|
|
516
581
|
return executeWMexQuery(variables, Types_1.QueryIds.SEARCH, Types_1.XWAPaths.xwa2_newsletters_search)
|
|
517
582
|
},
|
|
518
|
-
|
|
519
|
-
* Fetch recommended newsletters.
|
|
520
|
-
*
|
|
521
|
-
* @param {number} [limit=10]
|
|
522
|
-
* @param {number} [numFollowed] - Number of newsletters the user already follows (used for ranking)
|
|
523
|
-
*/
|
|
583
|
+
|
|
524
584
|
newsletterRecommended: async (limit = 10, numFollowed = null) => {
|
|
525
585
|
const variables = { limit }
|
|
526
586
|
if (numFollowed != null) variables.num_newsletters_followed = numFollowed
|
|
527
587
|
return executeWMexQuery(variables, Types_1.QueryIds.RECOMMENDED, Types_1.XWAPaths.xwa2_newsletters_recommended)
|
|
528
588
|
},
|
|
529
|
-
|
|
530
|
-
* Fetch newsletters similar to a given newsletter.
|
|
531
|
-
*
|
|
532
|
-
* @param {string} jid - Newsletter JID to find similar newsletters for
|
|
533
|
-
* @param {number} [limit=10]
|
|
534
|
-
*/
|
|
589
|
+
|
|
535
590
|
newsletterSimilar: async (jid, limit = 10) => {
|
|
536
591
|
return executeWMexQuery(
|
|
537
592
|
{ newsletter_id: jid, limit },
|
|
@@ -539,36 +594,19 @@ const makeNewsletterSocket = config => {
|
|
|
539
594
|
Types_1.XWAPaths.xwa2_newsletters_similar
|
|
540
595
|
)
|
|
541
596
|
},
|
|
542
|
-
|
|
543
|
-
* Fetch the list of newsletters the current user is following.
|
|
544
|
-
*
|
|
545
|
-
* @param {string} [startCursor] - Pagination cursor
|
|
546
|
-
* @param {number} [limit=20]
|
|
547
|
-
*/
|
|
597
|
+
|
|
548
598
|
newsletterFollowingList: async (startCursor = null, limit = 20) => {
|
|
549
599
|
const variables = { limit }
|
|
550
600
|
if (startCursor) variables.start_cursor = startCursor
|
|
551
601
|
return executeWMexQuery(variables, Types_1.QueryIds.FOLLOWING_LIST, Types_1.XWAPaths.xwa2_newsletter_following)
|
|
552
602
|
},
|
|
553
|
-
|
|
554
|
-
* Fetch admin insights/analytics for a newsletter.
|
|
555
|
-
*
|
|
556
|
-
* @param {string} jid - Newsletter JID
|
|
557
|
-
* @param {string} [period] - Time period e.g. 'LAST_7_DAYS', 'LAST_30_DAYS'
|
|
558
|
-
*/
|
|
603
|
+
|
|
559
604
|
newsletterInsights: async (jid, period = null) => {
|
|
560
605
|
const variables = { newsletter_id: jid }
|
|
561
606
|
if (period) variables.period = period
|
|
562
607
|
return executeWMexQuery(variables, Types_1.QueryIds.INSIGHTS, Types_1.XWAPaths.xwa2_newsletter_admin_insights)
|
|
563
608
|
},
|
|
564
|
-
|
|
565
|
-
* Fetch the list of users who voted in a newsletter poll.
|
|
566
|
-
*
|
|
567
|
-
* @param {string} jid - Newsletter JID
|
|
568
|
-
* @param {string} serverId - Server-side message ID of the poll
|
|
569
|
-
* @param {string} [option] - Poll option to filter voters by
|
|
570
|
-
* @param {string} [startCursor] - Pagination cursor
|
|
571
|
-
*/
|
|
609
|
+
|
|
572
610
|
newsletterPollVoterList: async (jid, serverId, option = null, startCursor = null) => {
|
|
573
611
|
const variables = { id: jid, server_id: serverId }
|
|
574
612
|
if (option != null) variables.option = option
|
|
@@ -579,13 +617,7 @@ const makeNewsletterSocket = config => {
|
|
|
579
617
|
Types_1.XWAPaths.xwa2_newsletters_poll_voter_list
|
|
580
618
|
)
|
|
581
619
|
},
|
|
582
|
-
|
|
583
|
-
* Fetch the list of users who reacted to a newsletter message.
|
|
584
|
-
*
|
|
585
|
-
* @param {string} jid - Newsletter JID
|
|
586
|
-
* @param {string} serverId - Server-side message sort ID
|
|
587
|
-
* @param {string} [startCursor] - Pagination cursor
|
|
588
|
-
*/
|
|
620
|
+
|
|
589
621
|
newsletterReactionSenders: async (jid, serverId, startCursor = null) => {
|
|
590
622
|
const variables = { id: jid, server_id: serverId }
|
|
591
623
|
if (startCursor) variables.start_cursor = startCursor
|
|
@@ -595,12 +627,7 @@ const makeNewsletterSocket = config => {
|
|
|
595
627
|
Types_1.XWAPaths.xwa2_newsletters_reaction_sender_list
|
|
596
628
|
)
|
|
597
629
|
},
|
|
598
|
-
|
|
599
|
-
* Block a user from a newsletter (admin action).
|
|
600
|
-
*
|
|
601
|
-
* @param {string} jid - Newsletter JID
|
|
602
|
-
* @param {string} userJid - JID of the user to block
|
|
603
|
-
*/
|
|
630
|
+
|
|
604
631
|
newsletterBlockUser: async (jid, userJid) => {
|
|
605
632
|
return executeWMexQuery(
|
|
606
633
|
{ newsletter_id: jid, user_id: userJid },
|
|
@@ -608,19 +635,15 @@ const makeNewsletterSocket = config => {
|
|
|
608
635
|
'xwa2_newsletter_block_user'
|
|
609
636
|
)
|
|
610
637
|
},
|
|
611
|
-
|
|
612
|
-
* Enable Wamo (paid subscription) for a newsletter.
|
|
613
|
-
*
|
|
614
|
-
* @param {string} jid - Newsletter JID
|
|
615
|
-
*/
|
|
638
|
+
|
|
616
639
|
newsletterEnableWamo: async jid => {
|
|
617
|
-
return executeWMexQuery(
|
|
640
|
+
return executeWMexQuery(
|
|
641
|
+
{ newsletter_id: jid },
|
|
642
|
+
Types_1.QueryIds.WAMO_ENABLE_SUB,
|
|
643
|
+
'xwa2_newsletter_wamo_enable_sub'
|
|
644
|
+
)
|
|
618
645
|
},
|
|
619
|
-
|
|
620
|
-
* Disable Wamo (paid subscription) for a newsletter.
|
|
621
|
-
*
|
|
622
|
-
* @param {string} jid - Newsletter JID
|
|
623
|
-
*/
|
|
646
|
+
|
|
624
647
|
newsletterDisableWamo: async jid => {
|
|
625
648
|
return executeWMexQuery(
|
|
626
649
|
{ newsletter_id: jid },
|
|
@@ -628,12 +651,7 @@ const makeNewsletterSocket = config => {
|
|
|
628
651
|
'xwa2_newsletter_wamo_disable_sub'
|
|
629
652
|
)
|
|
630
653
|
},
|
|
631
|
-
|
|
632
|
-
* Change the Wamo subscription tier or settings for a newsletter.
|
|
633
|
-
*
|
|
634
|
-
* @param {string} jid - Newsletter JID
|
|
635
|
-
* @param {object} subConfig - Subscription configuration (tier, price, etc.)
|
|
636
|
-
*/
|
|
654
|
+
|
|
637
655
|
newsletterChangeWamo: async (jid, subConfig) => {
|
|
638
656
|
return executeWMexQuery(
|
|
639
657
|
{ newsletter_id: jid, ...subConfig },
|
|
@@ -641,155 +659,137 @@ const makeNewsletterSocket = config => {
|
|
|
641
659
|
'xwa2_newsletter_wamo_change_sub'
|
|
642
660
|
)
|
|
643
661
|
},
|
|
644
|
-
|
|
645
|
-
* Fetch Wamo AFS age collection data.
|
|
646
|
-
* @param {string} jid - Newsletter JID
|
|
647
|
-
*/
|
|
662
|
+
|
|
648
663
|
wamoAfsAgeCollection: async jid =>
|
|
649
|
-
executeWMexQuery(
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
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
|
+
|
|
654
670
|
wamoAssetCollection: async jid =>
|
|
655
|
-
executeWMexQuery(
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
671
|
+
executeWMexQuery(
|
|
672
|
+
{ newsletter_id: jid },
|
|
673
|
+
Types_1.QueryIds.WAMO_ASSET_COLLECTION,
|
|
674
|
+
Types_1.XWAPaths.xwa2_wamo_asset_collection
|
|
675
|
+
),
|
|
676
|
+
|
|
660
677
|
wamoFetchAdhocNotice: async noticeId =>
|
|
661
|
-
executeWMexQuery(
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
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
|
+
|
|
666
684
|
wamoFetchIdentityToken: async jid =>
|
|
667
|
-
executeWMexQuery(
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
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
|
+
|
|
672
691
|
wamoSubComplianceInfo: async jid =>
|
|
673
|
-
executeWMexQuery(
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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
|
+
|
|
678
698
|
wamoUserIdVersion: async jid =>
|
|
679
|
-
executeWMexQuery(
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
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
|
+
|
|
685
705
|
wamoSetUserIdVersion: async (jid, version) =>
|
|
686
|
-
executeWMexQuery(
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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
|
+
|
|
691
712
|
newsletterLeave: async jid =>
|
|
692
713
|
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.LEAVE, Types_1.XWAPaths.xwa2_newsletter_leave_v2),
|
|
693
|
-
|
|
694
|
-
* Create a verified newsletter.
|
|
695
|
-
* @param {string} name - Newsletter name
|
|
696
|
-
* @param {string} [description]
|
|
697
|
-
*/
|
|
714
|
+
|
|
698
715
|
newsletterCreateVerified: async (name, description = null) =>
|
|
699
716
|
executeWMexQuery(
|
|
700
717
|
{ input: { name, description } },
|
|
701
718
|
Types_1.QueryIds.CREATE_VERIFIED,
|
|
702
719
|
Types_1.XWAPaths.xwa2_newsletter_create_verified
|
|
703
720
|
),
|
|
704
|
-
|
|
705
|
-
* Fetch newsletter enforcements (ban/restriction info).
|
|
706
|
-
* @param {string} jid - Newsletter JID
|
|
707
|
-
*/
|
|
721
|
+
|
|
708
722
|
newsletterEnforcements: async jid =>
|
|
709
|
-
executeWMexQuery(
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
723
|
+
executeWMexQuery(
|
|
724
|
+
{ newsletter_id: jid },
|
|
725
|
+
Types_1.QueryIds.ENFORCEMENTS,
|
|
726
|
+
Types_1.XWAPaths.xwa2_newsletter_enforcements
|
|
727
|
+
),
|
|
728
|
+
|
|
715
729
|
newsletterUserReports: async (jid, cursor = null) => {
|
|
716
730
|
const variables = { newsletter_id: jid }
|
|
717
731
|
if (cursor) variables.cursor = cursor
|
|
718
732
|
return executeWMexQuery(variables, Types_1.QueryIds.USER_REPORTS, Types_1.XWAPaths.xwa2_newsletter_user_reports)
|
|
719
733
|
},
|
|
720
|
-
|
|
721
|
-
* Create a report appeal for a newsletter.
|
|
722
|
-
* @param {string} jid - Newsletter JID
|
|
723
|
-
* @param {string} reason - Appeal reason text
|
|
724
|
-
*/
|
|
734
|
+
|
|
725
735
|
newsletterCreateReportAppeal: async (jid, reason) =>
|
|
726
736
|
executeWMexQuery(
|
|
727
737
|
{ newsletter_id: jid, reason },
|
|
728
738
|
Types_1.QueryIds.CREATE_REPORT_APPEAL,
|
|
729
739
|
Types_1.XWAPaths.xwa2_newsletter_create_report_appeal
|
|
730
740
|
),
|
|
731
|
-
|
|
732
|
-
* Check a newsletter link preview.
|
|
733
|
-
* @param {string} url - URL to preview
|
|
734
|
-
*/
|
|
741
|
+
|
|
735
742
|
newsletterLinkPreviewCheck: async url =>
|
|
736
|
-
executeWMexQuery(
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
743
|
+
executeWMexQuery(
|
|
744
|
+
{ url },
|
|
745
|
+
Types_1.QueryIds.LINK_PREVIEW_CHECK,
|
|
746
|
+
Types_1.XWAPaths.xwa2_newsletter_link_preview_check
|
|
747
|
+
),
|
|
748
|
+
|
|
742
749
|
newsletterUpdateVerification: async (jid, verification) =>
|
|
743
750
|
executeWMexQuery(
|
|
744
751
|
{ newsletter_id: jid, verification },
|
|
745
752
|
Types_1.QueryIds.UPDATE_VERIFICATION,
|
|
746
753
|
Types_1.XWAPaths.xwa2_newsletter_update_verification
|
|
747
754
|
),
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
* @param {string} jid - Newsletter JID
|
|
751
|
-
* @param {string} serverId - Server message ID
|
|
752
|
-
* @param {boolean} isPaidPartnership
|
|
753
|
-
*/
|
|
754
|
-
newsletterLabelPaidPartnership: async (jid, serverId, isPaidPartnership) =>
|
|
755
|
+
|
|
756
|
+
newsletterLabelPaidPartnership: async (jid, serverId, messageType = 'MESSAGE') =>
|
|
755
757
|
executeWMexQuery(
|
|
756
|
-
{ newsletter_id: jid, server_id: serverId,
|
|
758
|
+
{ newsletter_id: jid, server_id: String(serverId), message_type: messageType },
|
|
757
759
|
Types_1.QueryIds.LABEL_PAID_PARTNERSHIP,
|
|
758
760
|
Types_1.XWAPaths.xwa2_newsletter_label_paid_partnership
|
|
759
761
|
),
|
|
760
|
-
|
|
761
|
-
* Log newsletter exposure events (analytics).
|
|
762
|
-
* @param {{ newsletter_id: string, exposure_type: string }[]} events
|
|
763
|
-
*/
|
|
762
|
+
|
|
764
763
|
newsletterLogExposures: async events =>
|
|
765
764
|
executeWMexQuery({ events }, Types_1.QueryIds.LOG_EXPOSURES, Types_1.XWAPaths.xwa2_newsletter_log_exposures),
|
|
766
|
-
|
|
767
|
-
* Update user-specific newsletter setting (e.g. notification prefs).
|
|
768
|
-
* @param {string} jid - Newsletter JID
|
|
769
|
-
* @param {object} setting - Setting key/value
|
|
770
|
-
*/
|
|
765
|
+
|
|
771
766
|
newsletterUpdateUserSetting: async (jid, setting) =>
|
|
772
767
|
executeWMexQuery(
|
|
773
768
|
{ newsletter_id: jid, ...setting },
|
|
774
769
|
Types_1.QueryIds.UPDATE_USER_SETTING,
|
|
775
770
|
Types_1.XWAPaths.xwa2_newsletter_update_user_setting
|
|
776
771
|
),
|
|
777
|
-
|
|
778
|
-
* Fetch newsletter ranking features (ML signals).
|
|
779
|
-
* @param {string} jid - Newsletter JID
|
|
780
|
-
*/
|
|
772
|
+
|
|
781
773
|
newsletterRankingFeatures: async jid =>
|
|
782
774
|
executeWMexQuery(
|
|
783
775
|
{ newsletter_id: jid },
|
|
784
776
|
Types_1.QueryIds.RANKING_FEATURES,
|
|
785
777
|
Types_1.XWAPaths.xwa2_newsletter_ranking_features
|
|
786
778
|
),
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
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
793
|
newsletterSendViewReceipt: async (jid, serverMessageIds) => {
|
|
794
794
|
const ids = Array.isArray(serverMessageIds) ? serverMessageIds : [serverMessageIds]
|
|
795
795
|
const receiptId = generateMessageTag()
|