@badzz88/baileys 8.5.4 → 8.5.5
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 +75 -1256
- package/WAProto/index.d.ts +19729 -36122
- package/WAProto/index.js +132193 -178538
- package/engine-requirements.js +15 -7
- package/lib/Defaults/index.js +14 -22
- 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 +28 -39
- package/lib/Signal/lid-mapping.js +8 -28
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +11 -3
- package/lib/Socket/chats.js +319 -668
- package/lib/Socket/communities.js +89 -85
- package/lib/Socket/graphql.js +228 -435
- package/lib/Socket/groups.js +211 -132
- package/lib/Socket/index.js +7 -9
- package/lib/Socket/interactive-handler.js +60 -117
- package/lib/Socket/interop.js +175 -56
- package/lib/Socket/luxu.js +387 -0
- package/lib/Socket/managed-account.js +48 -79
- package/lib/Socket/messages-recv.js +340 -898
- package/lib/Socket/messages-send.js +160 -462
- package/lib/Socket/mex.js +53 -40
- package/lib/Socket/newsletter.js +295 -291
- package/lib/Socket/privacy.js +265 -77
- package/lib/Socket/registration.js +157 -164
- package/lib/Socket/socket.js +199 -181
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +227 -144
- package/lib/Store/keyed-db.js +108 -0
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +141 -25
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Mex.js +112 -0
- package/lib/Types/Newsletter.js +65 -96
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +57 -52
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +6 -2
- package/lib/Utils/chat-utils.js +38 -102
- package/lib/Utils/command-loader.d.ts +31 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +42 -0
- package/lib/Utils/crypto.js +84 -54
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +83 -316
- package/lib/Utils/event-buffer.js +61 -37
- package/lib/Utils/generics.js +103 -157
- package/lib/Utils/group-history.js +12 -3
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +5 -1
- package/lib/Utils/link-preview.js +8 -3
- package/lib/Utils/lt-hash.js +35 -2
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-retry-manager.js +92 -27
- package/lib/Utils/messages-media.js +130 -159
- package/lib/Utils/messages.js +566 -144
- package/lib/Utils/meta-ai-msmsg.js +202 -62
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +21 -19
- package/lib/Utils/offline-node-processor.js +8 -3
- package/lib/Utils/pre-key-manager.js +23 -13
- package/lib/Utils/process-message.js +106 -197
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +63 -28
- package/lib/Utils/stanza-ack.js +12 -39
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +7 -4
- package/lib/Utils/tc-token-utils.js +25 -20
- package/lib/Utils/use-multi-file-auth-state.js +14 -30
- package/lib/Utils/validate-connection.js +19 -59
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/WABinary/decode.js +16 -50
- package/lib/WABinary/encode.js +224 -54
- package/lib/WABinary/generic-utils.js +97 -7
- package/lib/WABinary/jid-utils.js +14 -27
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +1 -58
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +1 -7
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +7 -20
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
- package/lib/WAUSync/Protocols/index.js +0 -1
- package/lib/WAUSync/USyncQuery.js +6 -77
- package/lib/WAUSync/USyncUser.js +8 -16
- package/lib/WAUSync/index.js +0 -1
- package/lib/antiban.js +854 -608
- package/lib/index.js +1 -1
- package/package.json +20 -16
package/lib/Socket/newsletter.js
CHANGED
|
@@ -7,113 +7,9 @@ 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
|
-
|
|
110
10
|
const parseNewsletterCreateResponse = response => {
|
|
111
11
|
const { id, thread_metadata: thread, viewer_metadata: viewer } = response
|
|
112
|
-
|
|
113
|
-
thread.dsa_eligibility_countries ?? null,
|
|
114
|
-
thread.dsa_eligible_countries ?? null
|
|
115
|
-
)
|
|
116
|
-
const base = {
|
|
12
|
+
return {
|
|
117
13
|
id: id,
|
|
118
14
|
owner: undefined,
|
|
119
15
|
name: thread.name.text,
|
|
@@ -126,36 +22,66 @@ const parseNewsletterCreateResponse = response => {
|
|
|
126
22
|
id: thread.picture.id,
|
|
127
23
|
directPath: thread.picture.direct_path
|
|
128
24
|
},
|
|
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)
|
|
25
|
+
mute_state: viewer.mute
|
|
138
26
|
}
|
|
139
|
-
return base
|
|
140
27
|
}
|
|
141
28
|
const parseNewsletterMetadata = result => {
|
|
142
29
|
if (typeof result !== 'object' || result === null) {
|
|
143
30
|
return null
|
|
144
31
|
}
|
|
145
32
|
if ('id' in result && typeof result.id === 'string') {
|
|
146
|
-
return
|
|
33
|
+
return result
|
|
147
34
|
}
|
|
148
35
|
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
149
|
-
return
|
|
36
|
+
return result.result
|
|
150
37
|
}
|
|
151
38
|
return null
|
|
152
39
|
}
|
|
153
40
|
const makeNewsletterSocket = config => {
|
|
154
41
|
const sock = (0, aigroups_1.makeAIGroupsSocket)(config)
|
|
155
|
-
const
|
|
42
|
+
const encoder = new TextDecoder();
|
|
43
|
+
const { query, generateMessageTag } = sock
|
|
156
44
|
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
157
45
|
return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag)
|
|
158
46
|
}
|
|
47
|
+
const newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
48
|
+
tag: 'iq',
|
|
49
|
+
attrs: {
|
|
50
|
+
id: generateMessageTag(),
|
|
51
|
+
type: 'get',
|
|
52
|
+
xmlns: 'w:mex',
|
|
53
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
54
|
+
},
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
tag: 'query',
|
|
58
|
+
attrs: { 'query_id': queryId },
|
|
59
|
+
content: new TextEncoder().encode(JSON.stringify({
|
|
60
|
+
variables: {
|
|
61
|
+
'newsletter_id': jid,
|
|
62
|
+
...content
|
|
63
|
+
}
|
|
64
|
+
}))
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}));
|
|
68
|
+
|
|
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
|
+
|
|
159
85
|
const newsletterUpdate = async (jid, updates) => {
|
|
160
86
|
const variables = {
|
|
161
87
|
newsletter_id: jid,
|
|
@@ -187,7 +113,7 @@ const makeNewsletterSocket = config => {
|
|
|
187
113
|
return executeWMexQuery(
|
|
188
114
|
{ newsletter_id: jid },
|
|
189
115
|
Types_1.QueryIds.SUBSCRIBERS,
|
|
190
|
-
Types_1.XWAPaths.
|
|
116
|
+
Types_1.XWAPaths.xwa2_newsletter_subscribers
|
|
191
117
|
)
|
|
192
118
|
},
|
|
193
119
|
newsletterMetadata: async (type, key) => {
|
|
@@ -208,13 +134,13 @@ const makeNewsletterSocket = config => {
|
|
|
208
134
|
return parseNewsletterMetadata(result)
|
|
209
135
|
},
|
|
210
136
|
newsletterFollow: jid => {
|
|
211
|
-
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.
|
|
137
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_follow)
|
|
212
138
|
},
|
|
213
139
|
newsletterUnfollow: jid => {
|
|
214
140
|
return executeWMexQuery(
|
|
215
141
|
{ newsletter_id: jid },
|
|
216
142
|
Types_1.QueryIds.UNFOLLOW,
|
|
217
|
-
Types_1.XWAPaths.
|
|
143
|
+
Types_1.XWAPaths.xwa2_newsletter_unfollow
|
|
218
144
|
)
|
|
219
145
|
},
|
|
220
146
|
newsletterMute: jid => {
|
|
@@ -285,45 +211,6 @@ const makeNewsletterSocket = config => {
|
|
|
285
211
|
})
|
|
286
212
|
return result
|
|
287
213
|
},
|
|
288
|
-
|
|
289
|
-
newsletterGetServerId: async (jid, messageId, limit = 50) => {
|
|
290
|
-
console.log('[newsletterGetServerId] called jid:', jid, 'messageId:', messageId)
|
|
291
|
-
let result
|
|
292
|
-
try {
|
|
293
|
-
result = await query(
|
|
294
|
-
{
|
|
295
|
-
tag: 'iq',
|
|
296
|
-
attrs: {
|
|
297
|
-
id: generateMessageTag(),
|
|
298
|
-
type: 'get',
|
|
299
|
-
xmlns: 'newsletter',
|
|
300
|
-
to: jid
|
|
301
|
-
},
|
|
302
|
-
content: [{ tag: 'message_updates', attrs: { count: String(limit) } }]
|
|
303
|
-
},
|
|
304
|
-
5000
|
|
305
|
-
)
|
|
306
|
-
} catch (e) {
|
|
307
|
-
console.log('[newsletterGetServerId] query error/timeout:', e?.message)
|
|
308
|
-
return null
|
|
309
|
-
}
|
|
310
|
-
console.log('[newsletterGetServerId] result tag:', result?.tag, 'attrs:', JSON.stringify(result?.attrs))
|
|
311
|
-
if (!result) return null
|
|
312
|
-
const updatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'message_updates')
|
|
313
|
-
const messages = (0, WABinary_1.getBinaryNodeChildren)(updatesNode ?? result, 'message')
|
|
314
|
-
console.log(
|
|
315
|
-
'[newsletterGetServerId] messages count:',
|
|
316
|
-
messages.length,
|
|
317
|
-
'first attrs:',
|
|
318
|
-
JSON.stringify(messages[0]?.attrs)
|
|
319
|
-
)
|
|
320
|
-
for (const msg of messages) {
|
|
321
|
-
if (msg.attrs.message_id === messageId || msg.attrs.id === messageId) {
|
|
322
|
-
return msg.attrs.server_id ? +msg.attrs.server_id : null
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return null
|
|
326
|
-
},
|
|
327
214
|
subscribeNewsletterUpdates: async jid => {
|
|
328
215
|
const result = await query({
|
|
329
216
|
tag: 'iq',
|
|
@@ -358,7 +245,7 @@ const makeNewsletterSocket = config => {
|
|
|
358
245
|
await executeWMexQuery(
|
|
359
246
|
{ newsletter_id: jid, user_id: userJid },
|
|
360
247
|
Types_1.QueryIds.DEMOTE,
|
|
361
|
-
Types_1.XWAPaths.
|
|
248
|
+
Types_1.XWAPaths.xwa2_newsletter_demote
|
|
362
249
|
)
|
|
363
250
|
},
|
|
364
251
|
newsletterDelete: async jid => {
|
|
@@ -368,16 +255,22 @@ const makeNewsletterSocket = config => {
|
|
|
368
255
|
Types_1.XWAPaths.xwa2_newsletter_delete_v2
|
|
369
256
|
)
|
|
370
257
|
},
|
|
371
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Update newsletter category/topic
|
|
260
|
+
*/
|
|
372
261
|
newsletterUpdateCategory: async (jid, category) => {
|
|
373
262
|
return newsletterUpdate(jid, { topic: category })
|
|
374
263
|
},
|
|
375
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Update newsletter invite codes / settings
|
|
266
|
+
*/
|
|
376
267
|
newsletterUpdateSettings: async (jid, settings) => {
|
|
377
268
|
const variables = { newsletter_id: jid, updates: { settings } }
|
|
378
269
|
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update')
|
|
379
270
|
},
|
|
380
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Promote a subscriber to admin
|
|
273
|
+
*/
|
|
381
274
|
newsletterPromoteAdmin: async (jid, userJid) => {
|
|
382
275
|
await query({
|
|
383
276
|
tag: 'iq',
|
|
@@ -396,7 +289,9 @@ const makeNewsletterSocket = config => {
|
|
|
396
289
|
]
|
|
397
290
|
})
|
|
398
291
|
},
|
|
399
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Get newsletter view/reach statistics
|
|
294
|
+
*/
|
|
400
295
|
newsletterViewStats: async (jid, serverId) => {
|
|
401
296
|
const result = await query({
|
|
402
297
|
tag: 'iq',
|
|
@@ -415,7 +310,9 @@ const makeNewsletterSocket = config => {
|
|
|
415
310
|
})
|
|
416
311
|
return result
|
|
417
312
|
},
|
|
418
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Send a newsletter post via IQ (alternative to sendMessage for newsletters)
|
|
315
|
+
*/
|
|
419
316
|
newsletterSendPost: async (jid, content, options = {}) => {
|
|
420
317
|
const result = await query({
|
|
421
318
|
tag: 'iq',
|
|
@@ -435,21 +332,9 @@ const makeNewsletterSocket = config => {
|
|
|
435
332
|
})
|
|
436
333
|
return result
|
|
437
334
|
},
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Pin a newsletter message
|
|
337
|
+
*/
|
|
453
338
|
newsletterPinMessage: async (jid, serverId, durationSecs = 86400) => {
|
|
454
339
|
await query({
|
|
455
340
|
tag: 'iq',
|
|
@@ -467,7 +352,9 @@ const makeNewsletterSocket = config => {
|
|
|
467
352
|
]
|
|
468
353
|
})
|
|
469
354
|
},
|
|
470
|
-
|
|
355
|
+
/**
|
|
356
|
+
* Unpin a newsletter message
|
|
357
|
+
*/
|
|
471
358
|
newsletterUnpinMessage: async (jid, serverId) => {
|
|
472
359
|
await query({
|
|
473
360
|
tag: 'iq',
|
|
@@ -485,7 +372,12 @@ const makeNewsletterSocket = config => {
|
|
|
485
372
|
]
|
|
486
373
|
})
|
|
487
374
|
},
|
|
488
|
-
|
|
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
|
+
*/
|
|
489
381
|
newsletterInviteAdmin: async (jid, userJid) => {
|
|
490
382
|
return executeWMexQuery(
|
|
491
383
|
{ newsletter_id: jid, user_id: userJid },
|
|
@@ -493,7 +385,12 @@ const makeNewsletterSocket = config => {
|
|
|
493
385
|
Types_1.XWAPaths.xwa2_newsletter_admin_invite_create
|
|
494
386
|
)
|
|
495
387
|
},
|
|
496
|
-
|
|
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
|
+
*/
|
|
497
394
|
newsletterRevokeAdminInvite: async (jid, userJid) => {
|
|
498
395
|
return executeWMexQuery(
|
|
499
396
|
{ newsletter_id: jid, user_id: userJid },
|
|
@@ -501,7 +398,11 @@ const makeNewsletterSocket = config => {
|
|
|
501
398
|
Types_1.XWAPaths.xwa2_newsletter_admin_invite_revoke
|
|
502
399
|
)
|
|
503
400
|
},
|
|
504
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Accept an admin invite to a newsletter (called by the invitee).
|
|
403
|
+
*
|
|
404
|
+
* @param {string} jid - Newsletter JID
|
|
405
|
+
*/
|
|
505
406
|
newsletterAcceptAdminInvite: async jid => {
|
|
506
407
|
return executeWMexQuery(
|
|
507
408
|
{ newsletter_id: jid },
|
|
@@ -509,7 +410,18 @@ const makeNewsletterSocket = config => {
|
|
|
509
410
|
Types_1.XWAPaths.xwa2_newsletter_admin_invite_accept
|
|
510
411
|
)
|
|
511
412
|
},
|
|
512
|
-
|
|
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
|
+
*/
|
|
513
425
|
newsletterAdminMetadata: async (jid, options = {}) => {
|
|
514
426
|
const {
|
|
515
427
|
fetchPendingAdmins = true,
|
|
@@ -535,7 +447,12 @@ const makeNewsletterSocket = config => {
|
|
|
535
447
|
Types_1.XWAPaths.xwa2_newsletter_admin
|
|
536
448
|
)
|
|
537
449
|
},
|
|
538
|
-
|
|
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
|
+
*/
|
|
539
456
|
newsletterAdminProfileUpdate: async (jid, updates) => {
|
|
540
457
|
return executeWMexQuery(
|
|
541
458
|
{ newsletter_id: jid, updates },
|
|
@@ -543,18 +460,30 @@ const makeNewsletterSocket = config => {
|
|
|
543
460
|
Types_1.XWAPaths.xwa2_newsletter_admin_profile_update
|
|
544
461
|
)
|
|
545
462
|
},
|
|
546
|
-
|
|
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
|
+
*/
|
|
547
472
|
newsletterDirectoryList: async (options = {}) => {
|
|
548
473
|
const { limit = 20, interests = null, sortField = 'SUBSCRIBER_COUNT', sortOrder = 'DESC' } = options
|
|
549
474
|
const variables = { limit, sort_field: sortField, sort_order: sortOrder }
|
|
550
475
|
if (interests?.length) variables.interests = interests
|
|
551
|
-
return executeWMexQuery(
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
476
|
+
return executeWMexQuery(variables, Types_1.QueryIds.DIRECTORY_LIST, Types_1.XWAPaths.xwa2_newsletters_directory_list)
|
|
477
|
+
},
|
|
478
|
+
/**
|
|
479
|
+
* Search the newsletter directory.
|
|
480
|
+
*
|
|
481
|
+
* @param {string} searchText - Search query string
|
|
482
|
+
* @param {object} options
|
|
483
|
+
* @param {number} [options.limit=20]
|
|
484
|
+
* @param {string} [options.startCursor] - Pagination cursor
|
|
485
|
+
* @param {string[]} [options.categories] - Category filters
|
|
486
|
+
*/
|
|
558
487
|
newsletterDirectorySearch: async (searchText, options = {}) => {
|
|
559
488
|
const { limit = 20, startCursor = null, categories = null } = options
|
|
560
489
|
const variables = { search_text: searchText, limit }
|
|
@@ -566,7 +495,11 @@ const makeNewsletterSocket = config => {
|
|
|
566
495
|
Types_1.XWAPaths.xwa2_newsletters_directory_search
|
|
567
496
|
)
|
|
568
497
|
},
|
|
569
|
-
|
|
498
|
+
/**
|
|
499
|
+
* Fetch a preview of newsletters grouped by directory category.
|
|
500
|
+
*
|
|
501
|
+
* @param {number} [limit=5] - Newsletters per category
|
|
502
|
+
*/
|
|
570
503
|
newsletterDirectoryCategoryPreview: async (limit = 5) => {
|
|
571
504
|
return executeWMexQuery(
|
|
572
505
|
{ limit },
|
|
@@ -574,19 +507,35 @@ const makeNewsletterSocket = config => {
|
|
|
574
507
|
Types_1.XWAPaths.xwa2_newsletters_directory_category_preview
|
|
575
508
|
)
|
|
576
509
|
},
|
|
577
|
-
|
|
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
|
+
*/
|
|
578
517
|
newsletterSearch: async (query, limit = 20, startCursor = null) => {
|
|
579
518
|
const variables = { query, limit }
|
|
580
519
|
if (startCursor) variables.start_cursor = startCursor
|
|
581
520
|
return executeWMexQuery(variables, Types_1.QueryIds.SEARCH, Types_1.XWAPaths.xwa2_newsletters_search)
|
|
582
521
|
},
|
|
583
|
-
|
|
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
|
+
*/
|
|
584
528
|
newsletterRecommended: async (limit = 10, numFollowed = null) => {
|
|
585
529
|
const variables = { limit }
|
|
586
530
|
if (numFollowed != null) variables.num_newsletters_followed = numFollowed
|
|
587
531
|
return executeWMexQuery(variables, Types_1.QueryIds.RECOMMENDED, Types_1.XWAPaths.xwa2_newsletters_recommended)
|
|
588
532
|
},
|
|
589
|
-
|
|
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
|
+
*/
|
|
590
539
|
newsletterSimilar: async (jid, limit = 10) => {
|
|
591
540
|
return executeWMexQuery(
|
|
592
541
|
{ newsletter_id: jid, limit },
|
|
@@ -594,19 +543,36 @@ const makeNewsletterSocket = config => {
|
|
|
594
543
|
Types_1.XWAPaths.xwa2_newsletters_similar
|
|
595
544
|
)
|
|
596
545
|
},
|
|
597
|
-
|
|
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
|
+
*/
|
|
598
552
|
newsletterFollowingList: async (startCursor = null, limit = 20) => {
|
|
599
553
|
const variables = { limit }
|
|
600
554
|
if (startCursor) variables.start_cursor = startCursor
|
|
601
555
|
return executeWMexQuery(variables, Types_1.QueryIds.FOLLOWING_LIST, Types_1.XWAPaths.xwa2_newsletter_following)
|
|
602
556
|
},
|
|
603
|
-
|
|
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
|
+
*/
|
|
604
563
|
newsletterInsights: async (jid, period = null) => {
|
|
605
564
|
const variables = { newsletter_id: jid }
|
|
606
565
|
if (period) variables.period = period
|
|
607
566
|
return executeWMexQuery(variables, Types_1.QueryIds.INSIGHTS, Types_1.XWAPaths.xwa2_newsletter_admin_insights)
|
|
608
567
|
},
|
|
609
|
-
|
|
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
|
+
*/
|
|
610
576
|
newsletterPollVoterList: async (jid, serverId, option = null, startCursor = null) => {
|
|
611
577
|
const variables = { id: jid, server_id: serverId }
|
|
612
578
|
if (option != null) variables.option = option
|
|
@@ -617,7 +583,13 @@ const makeNewsletterSocket = config => {
|
|
|
617
583
|
Types_1.XWAPaths.xwa2_newsletters_poll_voter_list
|
|
618
584
|
)
|
|
619
585
|
},
|
|
620
|
-
|
|
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
|
+
*/
|
|
621
593
|
newsletterReactionSenders: async (jid, serverId, startCursor = null) => {
|
|
622
594
|
const variables = { id: jid, server_id: serverId }
|
|
623
595
|
if (startCursor) variables.start_cursor = startCursor
|
|
@@ -627,7 +599,12 @@ const makeNewsletterSocket = config => {
|
|
|
627
599
|
Types_1.XWAPaths.xwa2_newsletters_reaction_sender_list
|
|
628
600
|
)
|
|
629
601
|
},
|
|
630
|
-
|
|
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
|
+
*/
|
|
631
608
|
newsletterBlockUser: async (jid, userJid) => {
|
|
632
609
|
return executeWMexQuery(
|
|
633
610
|
{ newsletter_id: jid, user_id: userJid },
|
|
@@ -635,15 +612,19 @@ const makeNewsletterSocket = config => {
|
|
|
635
612
|
'xwa2_newsletter_block_user'
|
|
636
613
|
)
|
|
637
614
|
},
|
|
638
|
-
|
|
615
|
+
/**
|
|
616
|
+
* Enable Wamo (paid subscription) for a newsletter.
|
|
617
|
+
*
|
|
618
|
+
* @param {string} jid - Newsletter JID
|
|
619
|
+
*/
|
|
639
620
|
newsletterEnableWamo: async jid => {
|
|
640
|
-
return executeWMexQuery(
|
|
641
|
-
{ newsletter_id: jid },
|
|
642
|
-
Types_1.QueryIds.WAMO_ENABLE_SUB,
|
|
643
|
-
'xwa2_newsletter_wamo_enable_sub'
|
|
644
|
-
)
|
|
621
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ENABLE_SUB, 'xwa2_newsletter_wamo_enable_sub')
|
|
645
622
|
},
|
|
646
|
-
|
|
623
|
+
/**
|
|
624
|
+
* Disable Wamo (paid subscription) for a newsletter.
|
|
625
|
+
*
|
|
626
|
+
* @param {string} jid - Newsletter JID
|
|
627
|
+
*/
|
|
647
628
|
newsletterDisableWamo: async jid => {
|
|
648
629
|
return executeWMexQuery(
|
|
649
630
|
{ newsletter_id: jid },
|
|
@@ -651,7 +632,12 @@ const makeNewsletterSocket = config => {
|
|
|
651
632
|
'xwa2_newsletter_wamo_disable_sub'
|
|
652
633
|
)
|
|
653
634
|
},
|
|
654
|
-
|
|
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
|
+
*/
|
|
655
641
|
newsletterChangeWamo: async (jid, subConfig) => {
|
|
656
642
|
return executeWMexQuery(
|
|
657
643
|
{ newsletter_id: jid, ...subConfig },
|
|
@@ -659,137 +645,155 @@ const makeNewsletterSocket = config => {
|
|
|
659
645
|
'xwa2_newsletter_wamo_change_sub'
|
|
660
646
|
)
|
|
661
647
|
},
|
|
662
|
-
|
|
648
|
+
/**
|
|
649
|
+
* Fetch Wamo AFS age collection data.
|
|
650
|
+
* @param {string} jid - Newsletter JID
|
|
651
|
+
*/
|
|
663
652
|
wamoAfsAgeCollection: async jid =>
|
|
664
|
-
executeWMexQuery(
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
653
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_AFS_AGE_COLLECTION, Types_1.XWAPaths.xwa2_wamo_afs_age_collection),
|
|
654
|
+
/**
|
|
655
|
+
* Fetch Wamo asset collection (images/assets for Wamo UI).
|
|
656
|
+
* @param {string} jid - Newsletter JID
|
|
657
|
+
*/
|
|
670
658
|
wamoAssetCollection: async jid =>
|
|
671
|
-
executeWMexQuery(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
659
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_ASSET_COLLECTION, Types_1.XWAPaths.xwa2_wamo_asset_collection),
|
|
660
|
+
/**
|
|
661
|
+
* Fetch a Wamo ad-hoc notice by ID.
|
|
662
|
+
* @param {string} noticeId - Notice ID to fetch
|
|
663
|
+
*/
|
|
677
664
|
wamoFetchAdhocNotice: async noticeId =>
|
|
678
|
-
executeWMexQuery(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
665
|
+
executeWMexQuery({ notice_id: noticeId }, Types_1.QueryIds.WAMO_FETCH_ADHOC_NOTICE, Types_1.XWAPaths.xwa2_wamo_fetch_adhoc_notice_by_id),
|
|
666
|
+
/**
|
|
667
|
+
* Fetch the Wamo identity token for a newsletter.
|
|
668
|
+
* @param {string} jid - Newsletter JID
|
|
669
|
+
*/
|
|
684
670
|
wamoFetchIdentityToken: async jid =>
|
|
685
|
-
executeWMexQuery(
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
671
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_FETCH_IDENTITY_TOKEN, Types_1.XWAPaths.xwa2_wamo_fetch_identity_token),
|
|
672
|
+
/**
|
|
673
|
+
* Get Wamo subscription compliance info.
|
|
674
|
+
* @param {string} jid - Newsletter JID
|
|
675
|
+
*/
|
|
691
676
|
wamoSubComplianceInfo: async jid =>
|
|
692
|
-
executeWMexQuery(
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
677
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_SUB_COMPLIANCE_INFO, Types_1.XWAPaths.xwa2_wamo_sub_get_compliance_info),
|
|
678
|
+
/**
|
|
679
|
+
* Get the Wamo user ID version for a newsletter.
|
|
680
|
+
* @param {string} jid - Newsletter JID
|
|
681
|
+
*/
|
|
698
682
|
wamoUserIdVersion: async jid =>
|
|
699
|
-
executeWMexQuery(
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
683
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.WAMO_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_user_id_version),
|
|
684
|
+
/**
|
|
685
|
+
* Set the Wamo user ID version for a newsletter.
|
|
686
|
+
* @param {string} jid - Newsletter JID
|
|
687
|
+
* @param {number} version - Version to set
|
|
688
|
+
*/
|
|
705
689
|
wamoSetUserIdVersion: async (jid, version) =>
|
|
706
|
-
executeWMexQuery(
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
690
|
+
executeWMexQuery({ newsletter_id: jid, version }, Types_1.QueryIds.WAMO_SET_USER_ID_VERSION, Types_1.XWAPaths.xwa2_wamo_set_user_id_version),
|
|
691
|
+
/**
|
|
692
|
+
* Leave a newsletter (unsubscribe).
|
|
693
|
+
* @param {string} jid - Newsletter JID
|
|
694
|
+
*/
|
|
712
695
|
newsletterLeave: async jid =>
|
|
713
696
|
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.LEAVE, Types_1.XWAPaths.xwa2_newsletter_leave_v2),
|
|
714
|
-
|
|
697
|
+
/**
|
|
698
|
+
* Create a verified newsletter.
|
|
699
|
+
* @param {string} name - Newsletter name
|
|
700
|
+
* @param {string} [description]
|
|
701
|
+
*/
|
|
715
702
|
newsletterCreateVerified: async (name, description = null) =>
|
|
716
703
|
executeWMexQuery(
|
|
717
704
|
{ input: { name, description } },
|
|
718
705
|
Types_1.QueryIds.CREATE_VERIFIED,
|
|
719
706
|
Types_1.XWAPaths.xwa2_newsletter_create_verified
|
|
720
707
|
),
|
|
721
|
-
|
|
708
|
+
/**
|
|
709
|
+
* Fetch newsletter enforcements (ban/restriction info).
|
|
710
|
+
* @param {string} jid - Newsletter JID
|
|
711
|
+
*/
|
|
722
712
|
newsletterEnforcements: async jid =>
|
|
723
|
-
executeWMexQuery(
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
713
|
+
executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ENFORCEMENTS, Types_1.XWAPaths.xwa2_newsletter_enforcements),
|
|
714
|
+
/**
|
|
715
|
+
* Fetch user reports for a newsletter (admin action).
|
|
716
|
+
* @param {string} jid - Newsletter JID
|
|
717
|
+
* @param {string} [cursor] - Pagination cursor
|
|
718
|
+
*/
|
|
729
719
|
newsletterUserReports: async (jid, cursor = null) => {
|
|
730
720
|
const variables = { newsletter_id: jid }
|
|
731
721
|
if (cursor) variables.cursor = cursor
|
|
732
722
|
return executeWMexQuery(variables, Types_1.QueryIds.USER_REPORTS, Types_1.XWAPaths.xwa2_newsletter_user_reports)
|
|
733
723
|
},
|
|
734
|
-
|
|
724
|
+
/**
|
|
725
|
+
* Create a report appeal for a newsletter.
|
|
726
|
+
* @param {string} jid - Newsletter JID
|
|
727
|
+
* @param {string} reason - Appeal reason text
|
|
728
|
+
*/
|
|
735
729
|
newsletterCreateReportAppeal: async (jid, reason) =>
|
|
736
730
|
executeWMexQuery(
|
|
737
731
|
{ newsletter_id: jid, reason },
|
|
738
732
|
Types_1.QueryIds.CREATE_REPORT_APPEAL,
|
|
739
733
|
Types_1.XWAPaths.xwa2_newsletter_create_report_appeal
|
|
740
734
|
),
|
|
741
|
-
|
|
735
|
+
/**
|
|
736
|
+
* Check a newsletter link preview.
|
|
737
|
+
* @param {string} url - URL to preview
|
|
738
|
+
*/
|
|
742
739
|
newsletterLinkPreviewCheck: async url =>
|
|
743
|
-
executeWMexQuery(
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
740
|
+
executeWMexQuery({ url }, Types_1.QueryIds.LINK_PREVIEW_CHECK, Types_1.XWAPaths.xwa2_newsletter_link_preview_check),
|
|
741
|
+
/**
|
|
742
|
+
* Update newsletter verification status (admin/platform action).
|
|
743
|
+
* @param {string} jid - Newsletter JID
|
|
744
|
+
* @param {string} verification - Verification status
|
|
745
|
+
*/
|
|
749
746
|
newsletterUpdateVerification: async (jid, verification) =>
|
|
750
747
|
executeWMexQuery(
|
|
751
748
|
{ newsletter_id: jid, verification },
|
|
752
749
|
Types_1.QueryIds.UPDATE_VERIFICATION,
|
|
753
750
|
Types_1.XWAPaths.xwa2_newsletter_update_verification
|
|
754
751
|
),
|
|
755
|
-
|
|
756
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Label a newsletter post as paid partnership.
|
|
754
|
+
* @param {string} jid - Newsletter JID
|
|
755
|
+
* @param {string} serverId - Server message ID
|
|
756
|
+
* @param {boolean} isPaidPartnership
|
|
757
|
+
*/
|
|
758
|
+
newsletterLabelPaidPartnership: async (jid, serverId, isPaidPartnership) =>
|
|
757
759
|
executeWMexQuery(
|
|
758
|
-
{ newsletter_id: jid, server_id:
|
|
760
|
+
{ newsletter_id: jid, server_id: serverId, is_paid_partnership: isPaidPartnership },
|
|
759
761
|
Types_1.QueryIds.LABEL_PAID_PARTNERSHIP,
|
|
760
762
|
Types_1.XWAPaths.xwa2_newsletter_label_paid_partnership
|
|
761
763
|
),
|
|
762
|
-
|
|
764
|
+
/**
|
|
765
|
+
* Log newsletter exposure events (analytics).
|
|
766
|
+
* @param {{ newsletter_id: string, exposure_type: string }[]} events
|
|
767
|
+
*/
|
|
763
768
|
newsletterLogExposures: async events =>
|
|
764
769
|
executeWMexQuery({ events }, Types_1.QueryIds.LOG_EXPOSURES, Types_1.XWAPaths.xwa2_newsletter_log_exposures),
|
|
765
|
-
|
|
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
|
+
*/
|
|
766
775
|
newsletterUpdateUserSetting: async (jid, setting) =>
|
|
767
776
|
executeWMexQuery(
|
|
768
777
|
{ newsletter_id: jid, ...setting },
|
|
769
778
|
Types_1.QueryIds.UPDATE_USER_SETTING,
|
|
770
779
|
Types_1.XWAPaths.xwa2_newsletter_update_user_setting
|
|
771
780
|
),
|
|
772
|
-
|
|
781
|
+
/**
|
|
782
|
+
* Fetch newsletter ranking features (ML signals).
|
|
783
|
+
* @param {string} jid - Newsletter JID
|
|
784
|
+
*/
|
|
773
785
|
newsletterRankingFeatures: async jid =>
|
|
774
786
|
executeWMexQuery(
|
|
775
787
|
{ newsletter_id: jid },
|
|
776
788
|
Types_1.QueryIds.RANKING_FEATURES,
|
|
777
789
|
Types_1.XWAPaths.xwa2_newsletter_ranking_features
|
|
778
790
|
),
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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
|
-
|
|
791
|
+
/**
|
|
792
|
+
* Send view receipts for newsletter messages (marks them as seen).
|
|
793
|
+
* serverMessageIds: array of numeric server-side message IDs.
|
|
794
|
+
* Mirrors SendViewReceiptJob in the APK — builds a receipt stanza
|
|
795
|
+
* with type="view" and a <list> of <item server_id="..."/> children.
|
|
796
|
+
*/
|
|
793
797
|
newsletterSendViewReceipt: async (jid, serverMessageIds) => {
|
|
794
798
|
const ids = Array.isArray(serverMessageIds) ? serverMessageIds : [serverMessageIds]
|
|
795
799
|
const receiptId = generateMessageTag()
|