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