sanka-baileyss 2.3.2 → 2.3.3
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/WAProto/BotMetadata/BotMetadata.d.ts +594 -1
- package/WAProto/BotMetadata/BotMetadata.js +1910 -148
- package/WAProto/BotMetadata/BotMetadata.proto +36 -0
- package/WAProto/E2E/E2E.d.ts +570 -6
- package/WAProto/E2E/E2E.js +1591 -26
- package/WAProto/E2E/E2E.proto +10 -1
- package/WAProto/HistorySync/HistorySync.d.ts +806 -6
- package/WAProto/HistorySync/HistorySync.js +2193 -29
- package/WAProto/HistorySync/HistorySync.proto +2 -1
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +570 -6
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +1591 -26
- package/WAProto/StatusAttributions/StatusAttributions.d.ts +2 -1
- package/WAProto/StatusAttributions/StatusAttributions.js +7 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +1 -0
- package/WAProto/SyncAction/SyncAction.d.ts +230 -0
- package/WAProto/SyncAction/SyncAction.js +578 -2
- package/WAProto/SyncAction/SyncAction.proto +13 -1
- package/WAProto/Web/Web.d.ts +570 -6
- package/WAProto/Web/Web.js +1591 -26
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/index.d.ts +42 -25
- package/lib/Defaults/index.js +6 -2
- package/lib/Signal/libsignal.d.ts +1 -0
- package/lib/Socket/Client/index.js +13 -9
- package/lib/Socket/Client/types.d.ts +11 -10
- package/lib/Socket/Client/types.js +11 -7
- package/lib/Socket/Client/websocket.d.ts +9 -8
- package/lib/Socket/Client/websocket.js +52 -47
- package/lib/Socket/business.d.ts +185 -182
- package/lib/Socket/business.js +258 -249
- package/lib/Socket/chats.d.ts +90 -87
- package/lib/Socket/chats.js +1095 -888
- package/lib/Socket/community.d.ts +131 -0
- package/lib/Socket/community.js +369 -0
- package/lib/Socket/groups.d.ts +50 -41
- package/lib/Socket/groups.js +10 -3
- package/lib/Socket/index.d.ts +5 -1
- package/lib/Socket/index.js +19 -5
- package/lib/Socket/messages-recv.d.ts +6 -2
- package/lib/Socket/messages-recv.js +31 -8
- package/lib/Socket/messages-send.d.ts +5 -1
- package/lib/Socket/messages-send.js +1293 -1351
- package/lib/Socket/newsletter.d.ts +142 -135
- package/lib/Socket/newsletter.js +274 -230
- package/lib/Socket/socket.d.ts +37 -35
- package/lib/Socket/usync.d.ts +31 -30
- package/lib/Socket/usync.js +74 -62
- package/lib/Types/Auth.d.ts +89 -72
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Call.d.ts +11 -10
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +85 -62
- package/lib/Types/Chat.js +4 -1
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +209 -191
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +12 -27
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +41 -39
- package/lib/Types/Label.js +24 -21
- package/lib/Types/LabelAssociation.d.ts +18 -12
- package/lib/Types/LabelAssociation.js +6 -3
- package/lib/Types/Message.d.ts +3 -2
- package/lib/Types/Message.js +7 -3
- package/lib/Types/MexUpdates.d.ts +9 -0
- package/lib/Types/MexUpdates.js +18 -0
- package/lib/Types/Newsletter.d.ts +84 -67
- package/lib/Types/Newsletter.js +30 -23
- package/lib/Types/Product.d.ts +70 -56
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +46 -35
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +105 -101
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +37 -23
- package/lib/Types/State.js +13 -1
- package/lib/Types/USync.d.ts +21 -20
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +51 -42
- package/lib/Types/index.js +25 -19
- package/lib/Utils/auth-utils.d.ts +14 -11
- package/lib/Utils/auth-utils.js +189 -182
- package/lib/Utils/baileys-event-stream.d.ts +12 -10
- package/lib/Utils/baileys-event-stream.js +52 -46
- package/lib/Utils/business.d.ts +15 -8
- package/lib/Utils/business.js +229 -217
- package/lib/Utils/chat-utils.d.ts +22 -12
- package/lib/Utils/chat-utils.js +57 -27
- package/lib/Utils/crypto.d.ts +31 -15
- package/lib/Utils/crypto.js +136 -107
- package/lib/Utils/decode-wa-message.d.ts +34 -245
- package/lib/Utils/decode-wa-message.js +205 -217
- package/lib/Utils/event-buffer.d.ts +30 -26
- package/lib/Utils/event-buffer.js +519 -515
- package/lib/Utils/history.d.ts +2 -8
- package/lib/Utils/index.js +13 -9
- package/lib/Utils/link-preview.d.ts +16 -14
- package/lib/Utils/link-preview.js +100 -92
- package/lib/Utils/logger.d.ts +9 -7
- package/lib/Utils/logger.js +1 -1
- package/lib/Utils/lt-hash.d.ts +10 -8
- package/lib/Utils/lt-hash.js +49 -44
- package/lib/Utils/make-mutex.d.ts +4 -2
- package/lib/Utils/make-mutex.js +43 -39
- package/lib/Utils/messages-media.d.ts +75 -50
- package/lib/Utils/messages.d.ts +60 -35
- package/lib/Utils/messages.js +87 -8
- package/lib/Utils/noise-handler.d.ts +13 -12
- package/lib/Utils/noise-handler.js +143 -138
- package/lib/Utils/process-message.d.ts +32 -24
- package/lib/Utils/process-message.js +387 -367
- package/lib/Utils/signal.d.ts +24 -15
- package/lib/Utils/signal.js +143 -131
- package/lib/Utils/use-mongo-file-auth-state.d.ts +3 -2
- package/lib/Utils/use-mongo-file-auth-state.js +72 -63
- package/lib/Utils/use-multi-file-auth-state.d.ts +9 -8
- package/lib/Utils/use-multi-file-auth-state.js +110 -102
- package/lib/Utils/use-single-file-auth-state.d.ts +8 -7
- package/lib/Utils/use-single-file-auth-state.js +66 -61
- package/lib/Utils/validate-connection.d.ts +5 -2
- package/lib/Utils/validate-connection.js +7 -6
- package/lib/WABinary/constants.d.ts +24 -21
- package/lib/WABinary/constants.js +1302 -31
- package/lib/WABinary/decode.d.ts +4 -1
- package/lib/WABinary/decode.js +267 -234
- package/lib/WABinary/encode.d.ts +1 -0
- package/lib/WABinary/encode.js +248 -226
- package/lib/WABinary/generic-utils.d.ts +13 -1
- package/lib/WABinary/generic-utils.js +113 -96
- package/lib/WABinary/index.js +13 -9
- package/lib/WABinary/jid-utils.d.ts +23 -4
- package/lib/WABinary/jid-utils.js +58 -39
- package/lib/WABinary/types.d.ts +15 -11
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +14 -14
- package/lib/WAM/BinaryInfo.js +11 -8
- package/lib/WAM/constants.d.ts +34 -26
- package/lib/WAM/constants.js +15358 -15349
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +153 -144
- package/lib/WAM/index.js +13 -9
- package/lib/index.js +11 -11
- package/package.json +1 -2
- package/WASignalGroup/GroupProtocol.js +0 -1771
- package/WASignalGroup/ciphertext_message.js +0 -10
- package/WASignalGroup/group_cipher.js +0 -103
- package/WASignalGroup/group_session_builder.js +0 -39
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -17
- package/WASignalGroup/protobufs.js +0 -2
- package/WASignalGroup/queue_job.js +0 -64
- package/WASignalGroup/sender_chain_key.js +0 -38
- package/WASignalGroup/sender_key_distribution_message.js +0 -68
- package/WASignalGroup/sender_key_message.js +0 -79
- package/WASignalGroup/sender_key_name.js +0 -59
- package/WASignalGroup/sender_key_record.js +0 -47
- package/WASignalGroup/sender_key_state.js +0 -110
- package/WASignalGroup/sender_message_key.js +0 -30
package/lib/Socket/business.js
CHANGED
|
@@ -1,259 +1,268 @@
|
|
|
1
1
|
"use strict"
|
|
2
|
+
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
3
5
|
const business_1 = require("../Utils/business")
|
|
4
6
|
const WABinary_1 = require("../WABinary")
|
|
5
7
|
const generic_utils_1 = require("../WABinary/generic-utils")
|
|
6
8
|
const messages_recv_1 = require("./messages-recv")
|
|
9
|
+
|
|
7
10
|
const makeBusinessSocket = (config) => {
|
|
8
|
-
const
|
|
9
|
-
const { authState, query, waUploadToServer } =
|
|
10
|
-
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
11
|
-
jid = jid || authState.creds.me?.id
|
|
12
|
-
jid = WABinary_1.jidNormalizedUser(jid)
|
|
13
|
-
const queryParamNodes = [
|
|
14
|
-
{
|
|
15
|
-
tag: 'limit',
|
|
16
|
-
attrs: {},
|
|
17
|
-
content: Buffer.from((limit || 10).toString())
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
tag: 'width',
|
|
21
|
-
attrs: {},
|
|
22
|
-
content: Buffer.from('100')
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
tag: 'height',
|
|
26
|
-
attrs: {},
|
|
27
|
-
content: Buffer.from('100')
|
|
28
|
-
},
|
|
29
|
-
]
|
|
30
|
-
if (cursor) {
|
|
31
|
-
queryParamNodes.push({
|
|
32
|
-
tag: 'after',
|
|
33
|
-
attrs: {},
|
|
34
|
-
content: cursor
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
const result = await query({
|
|
38
|
-
tag: 'iq',
|
|
39
|
-
attrs: {
|
|
40
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
41
|
-
type: 'get',
|
|
42
|
-
xmlns: 'w:biz:catalog'
|
|
43
|
-
},
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
tag: 'product_catalog',
|
|
47
|
-
attrs: {
|
|
48
|
-
jid,
|
|
49
|
-
'allow_shop_source': 'true'
|
|
50
|
-
},
|
|
51
|
-
content: queryParamNodes
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
})
|
|
55
|
-
return business_1.parseCatalogNode(result)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
jid =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
content: [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
11
|
+
const suki = messages_recv_1.makeMessagesRecvSocket(config)
|
|
12
|
+
const { authState, query, waUploadToServer } = suki
|
|
13
|
+
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
14
|
+
jid = jid || authState.creds.me?.id
|
|
15
|
+
jid = WABinary_1.jidNormalizedUser(jid)
|
|
16
|
+
const queryParamNodes = [
|
|
17
|
+
{
|
|
18
|
+
tag: 'limit',
|
|
19
|
+
attrs: {},
|
|
20
|
+
content: Buffer.from((limit || 10).toString())
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
tag: 'width',
|
|
24
|
+
attrs: {},
|
|
25
|
+
content: Buffer.from('100')
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
tag: 'height',
|
|
29
|
+
attrs: {},
|
|
30
|
+
content: Buffer.from('100')
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
if (cursor) {
|
|
34
|
+
queryParamNodes.push({
|
|
35
|
+
tag: 'after',
|
|
36
|
+
attrs: {},
|
|
37
|
+
content: cursor
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
const result = await query({
|
|
41
|
+
tag: 'iq',
|
|
42
|
+
attrs: {
|
|
43
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
44
|
+
type: 'get',
|
|
45
|
+
xmlns: 'w:biz:catalog'
|
|
46
|
+
},
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
tag: 'product_catalog',
|
|
50
|
+
attrs: {
|
|
51
|
+
jid,
|
|
52
|
+
'allow_shop_source': 'true'
|
|
53
|
+
},
|
|
54
|
+
content: queryParamNodes
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
return business_1.parseCatalogNode(result)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const getCollections = async (jid, limit = 51) => {
|
|
62
|
+
jid = jid || authState.creds.me?.id
|
|
63
|
+
jid = WABinary_1.jidNormalizedUser(jid)
|
|
64
|
+
const result = await query({
|
|
65
|
+
tag: 'iq',
|
|
66
|
+
attrs: {
|
|
67
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
68
|
+
type: 'get',
|
|
69
|
+
xmlns: 'w:biz:catalog',
|
|
70
|
+
'smax_id': '35'
|
|
71
|
+
},
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
tag: 'collections',
|
|
75
|
+
attrs: {
|
|
76
|
+
'biz_jid': jid,
|
|
77
|
+
},
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
tag: 'collection_limit',
|
|
81
|
+
attrs: {},
|
|
82
|
+
content: Buffer.from(limit.toString())
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
tag: 'item_limit',
|
|
86
|
+
attrs: {},
|
|
87
|
+
content: Buffer.from(limit.toString())
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
tag: 'width',
|
|
91
|
+
attrs: {},
|
|
92
|
+
content: Buffer.from('100')
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
tag: 'height',
|
|
96
|
+
attrs: {},
|
|
97
|
+
content: Buffer.from('100')
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
return business_1.parseCollectionsNode(result)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const getOrderDetails = async (orderId, tokenBase64) => {
|
|
107
|
+
const result = await query({
|
|
108
|
+
tag: 'iq',
|
|
109
|
+
attrs: {
|
|
110
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
111
|
+
type: 'get',
|
|
112
|
+
xmlns: 'fb:thrift_iq',
|
|
113
|
+
'smax_id': '5'
|
|
114
|
+
},
|
|
115
|
+
content: [
|
|
116
|
+
{
|
|
117
|
+
tag: 'order',
|
|
118
|
+
attrs: {
|
|
119
|
+
op: 'get',
|
|
120
|
+
id: orderId
|
|
121
|
+
},
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
tag: 'image_dimensions',
|
|
125
|
+
attrs: {},
|
|
126
|
+
content: [
|
|
127
|
+
{
|
|
128
|
+
tag: 'width',
|
|
129
|
+
attrs: {},
|
|
130
|
+
content: Buffer.from('100')
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
tag: 'height',
|
|
134
|
+
attrs: {},
|
|
135
|
+
content: Buffer.from('100')
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
tag: 'token',
|
|
141
|
+
attrs: {},
|
|
142
|
+
content: Buffer.from(tokenBase64)
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
return business_1.parseOrderDetailsNode(result)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const productUpdate = async (productId, update) => {
|
|
152
|
+
update = await business_1.uploadingNecessaryImagesOfProduct(update, waUploadToServer)
|
|
153
|
+
const editNode = business_1.toProductNode(productId, update)
|
|
154
|
+
const result = await query({
|
|
155
|
+
tag: 'iq',
|
|
156
|
+
attrs: {
|
|
157
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
158
|
+
type: 'set',
|
|
159
|
+
xmlns: 'w:biz:catalog'
|
|
160
|
+
},
|
|
161
|
+
content: [
|
|
162
|
+
{
|
|
163
|
+
tag: 'product_catalog_edit',
|
|
164
|
+
attrs: { v: '1' },
|
|
165
|
+
content: [
|
|
166
|
+
editNode,
|
|
167
|
+
{
|
|
168
|
+
tag: 'width',
|
|
169
|
+
attrs: {},
|
|
170
|
+
content: '100'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
tag: 'height',
|
|
174
|
+
attrs: {},
|
|
175
|
+
content: '100'
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
})
|
|
181
|
+
const productCatalogEditNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_edit')
|
|
182
|
+
const productNode = generic_utils_1.getBinaryNodeChild(productCatalogEditNode, 'product')
|
|
183
|
+
return business_1.parseProductNode(productNode)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const productCreate = async (create) => {
|
|
187
|
+
// ensure isHidden is defined
|
|
188
|
+
create.isHidden = !!create.isHidden
|
|
189
|
+
create = await business_1.uploadingNecessaryImagesOfProduct(create, waUploadToServer)
|
|
190
|
+
const createNode = business_1.toProductNode(undefined, create)
|
|
191
|
+
const result = await query({
|
|
192
|
+
tag: 'iq',
|
|
193
|
+
attrs: {
|
|
194
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
195
|
+
type: 'set',
|
|
196
|
+
xmlns: 'w:biz:catalog'
|
|
197
|
+
},
|
|
198
|
+
content: [
|
|
199
|
+
{
|
|
200
|
+
tag: 'product_catalog_add',
|
|
201
|
+
attrs: { v: '1' },
|
|
202
|
+
content: [
|
|
203
|
+
createNode,
|
|
204
|
+
{
|
|
205
|
+
tag: 'width',
|
|
206
|
+
attrs: {},
|
|
207
|
+
content: '100'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
tag: 'height',
|
|
211
|
+
attrs: {},
|
|
212
|
+
content: '100'
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
const productCatalogAddNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_add')
|
|
219
|
+
const productNode = generic_utils_1.getBinaryNodeChild(productCatalogAddNode, 'product')
|
|
220
|
+
return business_1.parseProductNode(productNode)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const productDelete = async (productIds) => {
|
|
224
|
+
const result = await query({
|
|
225
|
+
tag: 'iq',
|
|
226
|
+
attrs: {
|
|
227
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
228
|
+
type: 'set',
|
|
229
|
+
xmlns: 'w:biz:catalog'
|
|
230
|
+
},
|
|
231
|
+
content: [
|
|
232
|
+
{
|
|
233
|
+
tag: 'product_catalog_delete',
|
|
234
|
+
attrs: { v: '1' },
|
|
235
|
+
content: productIds.map(id => ({
|
|
236
|
+
tag: 'product',
|
|
237
|
+
attrs: {},
|
|
238
|
+
content: [
|
|
239
|
+
{
|
|
240
|
+
tag: 'id',
|
|
241
|
+
attrs: {},
|
|
242
|
+
content: Buffer.from(id)
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}))
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
})
|
|
249
|
+
const productCatalogDelNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_delete')
|
|
250
|
+
return {
|
|
251
|
+
deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
...suki,
|
|
256
|
+
logger: config.logger,
|
|
257
|
+
getOrderDetails,
|
|
258
|
+
getCatalog,
|
|
259
|
+
getCollections,
|
|
260
|
+
productCreate,
|
|
261
|
+
productDelete,
|
|
262
|
+
productUpdate
|
|
263
|
+
}
|
|
256
264
|
}
|
|
265
|
+
|
|
257
266
|
module.exports = {
|
|
258
|
-
makeBusinessSocket
|
|
267
|
+
makeBusinessSocket
|
|
259
268
|
}
|