@skyzopedia/baileys-mod 3.0.9 → 4.0.1
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/lib/Socket/messages-send.js +1008 -1030
- package/lib/Socket/socket.js +1 -1
- package/lib/Utils/messages.js +842 -711
- package/lib/WABinary/generic-utils.js +165 -89
- package/package.json +1 -1
- package/lib/Socket/newsletter.js.bak +0 -247
|
@@ -1,113 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
import { proto } from
|
|
3
|
-
import {
|
|
4
|
-
import {} from
|
|
5
|
-
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
import {} from './types.js';
|
|
4
|
+
import { unixTimestampSeconds } from '../Utils/index.js';
|
|
5
|
+
|
|
6
6
|
export const getBinaryNodeChildren = (node, childTag) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
if (Array.isArray(node?.content)) {
|
|
8
|
+
return node.content.filter(item => item.tag === childTag);
|
|
9
|
+
}
|
|
10
|
+
return [];
|
|
11
11
|
};
|
|
12
|
-
//=======================================================//
|
|
13
12
|
export const getAllBinaryNodeChildren = ({ content }) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (Array.isArray(content)) {
|
|
14
|
+
return content;
|
|
15
|
+
}
|
|
16
|
+
return [];
|
|
18
17
|
};
|
|
19
|
-
//=======================================================//
|
|
20
18
|
export const getBinaryNodeChild = (node, childTag) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if (Array.isArray(node?.content)) {
|
|
20
|
+
return node?.content.find(item => item.tag === childTag);
|
|
21
|
+
}
|
|
24
22
|
};
|
|
25
|
-
//=======================================================//
|
|
26
23
|
export const getBinaryNodeChildBuffer = (node, childTag) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
const child = getBinaryNodeChild(node, childTag)?.content;
|
|
25
|
+
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
26
|
+
return child;
|
|
27
|
+
}
|
|
31
28
|
};
|
|
32
|
-
//=======================================================//
|
|
33
29
|
export const getBinaryNodeChildString = (node, childTag) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
const child = getBinaryNodeChild(node, childTag)?.content;
|
|
31
|
+
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
32
|
+
return Buffer.from(child).toString('utf-8');
|
|
33
|
+
}
|
|
34
|
+
else if (typeof child === 'string') {
|
|
35
|
+
return child;
|
|
36
|
+
}
|
|
41
37
|
};
|
|
42
|
-
//=======================================================//
|
|
43
38
|
export const getBinaryNodeChildUInt = (node, childTag, length) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const buff = getBinaryNodeChildBuffer(node, childTag);
|
|
40
|
+
if (buff) {
|
|
41
|
+
return bufferToUInt(buff, length);
|
|
42
|
+
}
|
|
48
43
|
};
|
|
49
|
-
//=======================================================//
|
|
50
44
|
export const assertNodeErrorFree = (node) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
const errNode = getBinaryNodeChild(node, 'error');
|
|
46
|
+
if (errNode) {
|
|
47
|
+
throw new Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
|
|
48
|
+
}
|
|
55
49
|
};
|
|
56
|
-
//=======================================================//
|
|
57
50
|
export const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
const nodes = getBinaryNodeChildren(node, tag);
|
|
52
|
+
const dict = nodes.reduce((dict, { attrs }) => {
|
|
53
|
+
if (typeof attrs.name === 'string') {
|
|
54
|
+
dict[attrs.name] = attrs.value || attrs.config_value;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
dict[attrs.config_code] = attrs.value || attrs.config_value;
|
|
58
|
+
}
|
|
59
|
+
return dict;
|
|
60
|
+
}, {});
|
|
66
61
|
return dict;
|
|
67
|
-
}, {});
|
|
68
|
-
return dict;
|
|
69
62
|
};
|
|
70
|
-
//=======================================================//
|
|
71
63
|
export const getBinaryNodeMessages = ({ content }) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
const msgs = [];
|
|
65
|
+
if (Array.isArray(content)) {
|
|
66
|
+
for (const item of content) {
|
|
67
|
+
if (item.tag === 'message') {
|
|
68
|
+
msgs.push(proto.WebMessageInfo.decode(item.content));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
78
71
|
}
|
|
79
|
-
|
|
80
|
-
return msgs;
|
|
72
|
+
return msgs;
|
|
81
73
|
};
|
|
82
|
-
//=======================================================//
|
|
83
74
|
function bufferToUInt(e, t) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
let a = 0;
|
|
76
|
+
for (let i = 0; i < t; i++) {
|
|
77
|
+
a = 256 * a + e[i];
|
|
78
|
+
}
|
|
79
|
+
return a;
|
|
89
80
|
}
|
|
90
|
-
|
|
91
|
-
const tabs = (n) => "\t".repeat(n);
|
|
81
|
+
const tabs = (n) => '\t'.repeat(n);
|
|
92
82
|
export function binaryNodeToString(node, i = 0) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
83
|
+
if (!node) {
|
|
84
|
+
return node;
|
|
85
|
+
}
|
|
86
|
+
if (typeof node === 'string') {
|
|
87
|
+
return tabs(i) + node;
|
|
88
|
+
}
|
|
89
|
+
if (node instanceof Uint8Array) {
|
|
90
|
+
return tabs(i) + Buffer.from(node).toString('hex');
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(node)) {
|
|
93
|
+
return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
|
|
94
|
+
}
|
|
95
|
+
const children = binaryNodeToString(node.content, i + 1);
|
|
96
|
+
const tag = `<${node.tag} ${Object.entries(node.attrs || {})
|
|
97
|
+
.filter(([, v]) => v !== undefined)
|
|
98
|
+
.map(([k, v]) => `${k}='${v}'`)
|
|
99
|
+
.join(' ')}`;
|
|
100
|
+
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
101
|
+
return tag + content;
|
|
102
|
+
}
|
|
103
|
+
export const getBinaryNodeFilter = (node) => {
|
|
104
|
+
if (!Array.isArray(node)) return false
|
|
105
|
+
|
|
106
|
+
return node.some(item =>
|
|
107
|
+
['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
|
|
108
|
+
['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
|
|
109
|
+
['hsm', 'biz'].includes(item?.tag) ||
|
|
110
|
+
['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'
|
|
111
|
+
)
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
export const getAdditionalNode = (name) => {
|
|
114
|
+
if (name) name = name.toLowerCase()
|
|
115
|
+
const ts = unixTimestampSeconds(new Date()) - 77980457
|
|
116
|
+
|
|
117
|
+
const order_response_name = {
|
|
118
|
+
review_and_pay: 'order_details',
|
|
119
|
+
review_order: 'order_status',
|
|
120
|
+
payment_info: 'payment_info',
|
|
121
|
+
payment_status: 'payment_status',
|
|
122
|
+
payment_method: 'payment_method'
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const flow_name = {
|
|
126
|
+
cta_catalog: 'cta_catalog',
|
|
127
|
+
mpm: 'mpm',
|
|
128
|
+
call_request: 'call_permission_request',
|
|
129
|
+
view_catalog: 'automated_greeting_message_view_catalog',
|
|
130
|
+
wa_pay_detail: 'wa_payment_transaction_details',
|
|
131
|
+
send_location: 'send_location',
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if(order_response_name[name]) {
|
|
135
|
+
return [{
|
|
136
|
+
tag: 'biz',
|
|
137
|
+
attrs: {
|
|
138
|
+
native_flow_name: order_response_name[name]
|
|
139
|
+
},
|
|
140
|
+
content: []
|
|
141
|
+
}]
|
|
142
|
+
} else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
|
|
143
|
+
return [{
|
|
144
|
+
tag: 'biz',
|
|
145
|
+
attrs: {
|
|
146
|
+
actual_actors: '2',
|
|
147
|
+
host_storage: '2',
|
|
148
|
+
privacy_mode_ts: `${ts}`
|
|
149
|
+
},
|
|
150
|
+
content: [{
|
|
151
|
+
tag: 'engagement',
|
|
152
|
+
attrs: {
|
|
153
|
+
customer_service_state: 'open',
|
|
154
|
+
conversation_state: 'open'
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
tag: 'interactive',
|
|
158
|
+
attrs: {
|
|
159
|
+
type: 'native_flow',
|
|
160
|
+
v: '1'
|
|
161
|
+
},
|
|
162
|
+
content: [{
|
|
163
|
+
tag: 'native_flow',
|
|
164
|
+
attrs: {
|
|
165
|
+
v: '9',
|
|
166
|
+
name: flow_name[name] ?? 'mixed',
|
|
167
|
+
},
|
|
168
|
+
content: []
|
|
169
|
+
}]
|
|
170
|
+
}]
|
|
171
|
+
}]
|
|
172
|
+
} else {
|
|
173
|
+
return [{
|
|
174
|
+
tag: 'biz',
|
|
175
|
+
attrs: {
|
|
176
|
+
actual_actors: '2',
|
|
177
|
+
host_storage: '2',
|
|
178
|
+
privacy_mode_ts: `${ts}`
|
|
179
|
+
},
|
|
180
|
+
content: [{
|
|
181
|
+
tag: 'engagement',
|
|
182
|
+
attrs: {
|
|
183
|
+
customer_service_state: 'open',
|
|
184
|
+
conversation_state: 'open'
|
|
185
|
+
}
|
|
186
|
+
}]
|
|
187
|
+
}]
|
|
188
|
+
}
|
|
189
|
+
}
|
package/package.json
CHANGED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
//=======================================================//
|
|
2
|
-
import { executeWMexQuery as genericExecuteWMexQuery } from "./mex.js";
|
|
3
|
-
import { generateProfilePicture } from "../Utils/messages-media.js";
|
|
4
|
-
import { getBinaryNodeChild } from "../WABinary/index.js";
|
|
5
|
-
import { QueryIds, XWAPaths } from "../Types/index.js";
|
|
6
|
-
import { makeGroupsSocket } from "./groups.js";
|
|
7
|
-
//=======================================================//
|
|
8
|
-
|
|
9
|
-
const extractNewsletterMetadata = (node, isCreate) => {
|
|
10
|
-
const result = getBinaryNodeChild(node, 'result')?.content?.toString()
|
|
11
|
-
const metadataPath = JSON.parse(result).data[isCreate ? XWAPaths.xwa2_newsletter_create : "xwa2_newsletter"]
|
|
12
|
-
|
|
13
|
-
const metadata = {
|
|
14
|
-
id: metadataPath?.id,
|
|
15
|
-
state: metadataPath?.state?.type,
|
|
16
|
-
creation_time: +metadataPath?.thread_metadata?.creation_time,
|
|
17
|
-
name: metadataPath?.thread_metadata?.name?.text,
|
|
18
|
-
nameTime: +metadataPath?.thread_metadata?.name?.update_time,
|
|
19
|
-
description: metadataPath?.thread_metadata?.description?.text,
|
|
20
|
-
descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
|
|
21
|
-
invite: metadataPath?.thread_metadata?.invite,
|
|
22
|
-
handle: metadataPath?.thread_metadata?.handle,
|
|
23
|
-
reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
|
|
24
|
-
subscribers: +metadataPath?.thread_metadata?.subscribers_count,
|
|
25
|
-
verification: metadataPath?.thread_metadata?.verification,
|
|
26
|
-
viewer_metadata: metadataPath?.viewer_metadata
|
|
27
|
-
}
|
|
28
|
-
return metadata
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const parseNewsletterCreateResponse = (response) => {
|
|
32
|
-
const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
|
|
33
|
-
return {
|
|
34
|
-
id: id,
|
|
35
|
-
owner: undefined,
|
|
36
|
-
name: thread.name.text,
|
|
37
|
-
creation_time: parseInt(thread.creation_time, 10),
|
|
38
|
-
description: thread.description.text,
|
|
39
|
-
invite: thread.invite,
|
|
40
|
-
subscribers: parseInt(thread.subscribers_count, 10),
|
|
41
|
-
verification: thread.verification,
|
|
42
|
-
picture: {
|
|
43
|
-
id: thread.picture.id,
|
|
44
|
-
directPath: thread.picture.direct_path
|
|
45
|
-
},
|
|
46
|
-
mute_state: viewer.mute
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
const parseNewsletterMetadata = (result) => {
|
|
50
|
-
if (typeof result !== "object" || result === null) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
if ("id" in result && typeof result.id === "string") {
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
if ("result" in result && typeof result.result === "object" && result.result !== null && "id" in result.result) {
|
|
57
|
-
return result.result;
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const makeNewsletterSocket = (config) => {
|
|
63
|
-
const sock = makeGroupsSocket(config);
|
|
64
|
-
const { query, generateMessageTag } = sock;
|
|
65
|
-
const encoder = new TextEncoder()
|
|
66
|
-
const newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
67
|
-
tag: 'iq',
|
|
68
|
-
attrs: {
|
|
69
|
-
id: generateMessageTag(),
|
|
70
|
-
type: 'get',
|
|
71
|
-
xmlns: 'w:mex',
|
|
72
|
-
to: "@s.whatsapp.net",
|
|
73
|
-
},
|
|
74
|
-
content: [
|
|
75
|
-
{
|
|
76
|
-
tag: 'query',
|
|
77
|
-
attrs: { 'query_id': queryId },
|
|
78
|
-
content: encoder.encode(JSON.stringify({
|
|
79
|
-
variables: {
|
|
80
|
-
'newsletter_id': jid,
|
|
81
|
-
...content
|
|
82
|
-
}
|
|
83
|
-
}))
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
}))
|
|
87
|
-
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
88
|
-
return genericExecuteWMexQuery(variables, queryId, dataPath, query, generateMessageTag);
|
|
89
|
-
};
|
|
90
|
-
const newsletterMetadata = async (type, key, role) => {
|
|
91
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
92
|
-
input: {
|
|
93
|
-
key,
|
|
94
|
-
type: type.toUpperCase(),
|
|
95
|
-
view_role: role || 'GUEST'
|
|
96
|
-
},
|
|
97
|
-
fetch_viewer_metadata: true,
|
|
98
|
-
fetch_full_image: true,
|
|
99
|
-
fetch_creation_time: true
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
return extractNewsletterMetadata(result)
|
|
103
|
-
}
|
|
104
|
-
const newsletterUpdate = async (jid, updates) => {
|
|
105
|
-
const variables = {
|
|
106
|
-
newsletter_id: jid,
|
|
107
|
-
updates: {
|
|
108
|
-
...updates,
|
|
109
|
-
settings: null
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
return executeWMexQuery(variables, QueryIds.UPDATE_METADATA, "xwa2_newsletter_update");
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
...sock,
|
|
116
|
-
newsletterCreate: async (name, description) => {
|
|
117
|
-
const variables = {
|
|
118
|
-
input: {
|
|
119
|
-
name,
|
|
120
|
-
description: description ?? null
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const rawResponse = await executeWMexQuery(variables, QueryIds.CREATE, XWAPaths.xwa2_newsletter_create);
|
|
124
|
-
return parseNewsletterCreateResponse(rawResponse);
|
|
125
|
-
},
|
|
126
|
-
newsletterUpdate,
|
|
127
|
-
newsletterSubscribers: async (jid) => {
|
|
128
|
-
return executeWMexQuery({ newsletter_id: jid }, QueryIds.SUBSCRIBERS, XWAPaths.xwa2_newsletter_subscribers);
|
|
129
|
-
},
|
|
130
|
-
newsletterMetadata,
|
|
131
|
-
newsletterFetchAllParticipating: async () => {
|
|
132
|
-
const data = {}
|
|
133
|
-
|
|
134
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.SUBSCRIBERS)
|
|
135
|
-
const child = JSON.parse(getBinaryNodeChild(result, 'result')?.content?.toString())
|
|
136
|
-
const newsletters = child.data["xwa2_newsletter_subscribed"]
|
|
137
|
-
|
|
138
|
-
for (const i of newsletters) {
|
|
139
|
-
if (i.id == null) continue
|
|
140
|
-
|
|
141
|
-
const metadata = await newsletterMetadata('JID', i.id)
|
|
142
|
-
if (metadata.id !== null) data[metadata.id] = metadata
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return data
|
|
146
|
-
},
|
|
147
|
-
newsletterUnfollow: async (jid) => {
|
|
148
|
-
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW)
|
|
149
|
-
},
|
|
150
|
-
newsletterFollow: async (jid) => {
|
|
151
|
-
await newsletterWMexQuery(jid, QueryIds.FOLLOW)
|
|
152
|
-
},
|
|
153
|
-
newsletterMute: (jid) => {
|
|
154
|
-
return executeWMexQuery({ newsletter_id: jid }, QueryIds.MUTE, XWAPaths.xwa2_newsletter_mute_v2);
|
|
155
|
-
},
|
|
156
|
-
newsletterUnmute: (jid) => {
|
|
157
|
-
return executeWMexQuery({ newsletter_id: jid }, QueryIds.UNMUTE, XWAPaths.xwa2_newsletter_unmute_v2);
|
|
158
|
-
},
|
|
159
|
-
newsletterUpdateName: async (jid, name) => {
|
|
160
|
-
return await newsletterUpdate(jid, { name });
|
|
161
|
-
},
|
|
162
|
-
newsletterUpdateDescription: async (jid, description) => {
|
|
163
|
-
return await newsletterUpdate(jid, { description });
|
|
164
|
-
},
|
|
165
|
-
newsletterUpdatePicture: async (jid, content) => {
|
|
166
|
-
const { img } = await generateProfilePicture(content);
|
|
167
|
-
return await newsletterUpdate(jid, { picture: img.toString("base64") });
|
|
168
|
-
},
|
|
169
|
-
newsletterRemovePicture: async (jid) => {
|
|
170
|
-
return await newsletterUpdate(jid, { picture: "" });
|
|
171
|
-
},
|
|
172
|
-
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
173
|
-
await query({
|
|
174
|
-
tag: "message",
|
|
175
|
-
attrs: {
|
|
176
|
-
to: jid,
|
|
177
|
-
...(reaction ? {} : { edit: "7" }),
|
|
178
|
-
type: "reaction",
|
|
179
|
-
server_id: serverId,
|
|
180
|
-
id: generateMessageTag()
|
|
181
|
-
},
|
|
182
|
-
content: [
|
|
183
|
-
{
|
|
184
|
-
tag: "reaction",
|
|
185
|
-
attrs: reaction ? { code: reaction } : {}
|
|
186
|
-
}
|
|
187
|
-
]
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
191
|
-
const messageUpdateAttrs = {
|
|
192
|
-
count: count.toString()
|
|
193
|
-
};
|
|
194
|
-
if (typeof since === "number") {
|
|
195
|
-
messageUpdateAttrs.since = since.toString();
|
|
196
|
-
}
|
|
197
|
-
if (after) {
|
|
198
|
-
messageUpdateAttrs.after = after.toString();
|
|
199
|
-
}
|
|
200
|
-
const result = await query({
|
|
201
|
-
tag: "iq",
|
|
202
|
-
attrs: {
|
|
203
|
-
id: generateMessageTag(),
|
|
204
|
-
type: "get",
|
|
205
|
-
xmlns: "newsletter",
|
|
206
|
-
to: jid
|
|
207
|
-
},
|
|
208
|
-
content: [
|
|
209
|
-
{
|
|
210
|
-
tag: "message_updates",
|
|
211
|
-
attrs: messageUpdateAttrs
|
|
212
|
-
}
|
|
213
|
-
]
|
|
214
|
-
});
|
|
215
|
-
return result;
|
|
216
|
-
},
|
|
217
|
-
subscribeNewsletterUpdates: async (jid) => {
|
|
218
|
-
const result = await query({
|
|
219
|
-
tag: "iq",
|
|
220
|
-
attrs: {
|
|
221
|
-
id: generateMessageTag(),
|
|
222
|
-
type: "set",
|
|
223
|
-
xmlns: "newsletter",
|
|
224
|
-
to: jid
|
|
225
|
-
},
|
|
226
|
-
content: [{ tag: "live_updates", attrs: {}, content: [] }]
|
|
227
|
-
});
|
|
228
|
-
const liveUpdatesNode = getBinaryNodeChild(result, "live_updates");
|
|
229
|
-
const duration = liveUpdatesNode?.attrs?.duration;
|
|
230
|
-
return duration ? { duration: duration } : null;
|
|
231
|
-
},
|
|
232
|
-
newsletterAdminCount: async (jid) => {
|
|
233
|
-
const response = await executeWMexQuery({ newsletter_id: jid }, QueryIds.ADMIN_COUNT, XWAPaths.xwa2_newsletter_admin_count);
|
|
234
|
-
return response.admin_count;
|
|
235
|
-
},
|
|
236
|
-
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
237
|
-
await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, QueryIds.CHANGE_OWNER, XWAPaths.xwa2_newsletter_change_owner);
|
|
238
|
-
},
|
|
239
|
-
newsletterDemote: async (jid, userJid) => {
|
|
240
|
-
await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, QueryIds.DEMOTE, XWAPaths.xwa2_newsletter_demote);
|
|
241
|
-
},
|
|
242
|
-
newsletterDelete: async (jid) => {
|
|
243
|
-
await executeWMexQuery({ newsletter_id: jid }, QueryIds.DELETE, XWAPaths.xwa2_newsletter_delete_v2);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
//=======================================================//
|