@neelegirl/baileys 1.5.2 → 1.5.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/LICENSE +21 -21
- package/README.md +195 -187
- package/WAProto/WAProto.proto +537 -236
- package/WAProto/index.d.ts +5971 -2388
- package/WAProto/index.js +17298 -6513
- package/lib/Defaults/baileys-version.json +3 -3
- package/lib/Defaults/index.d.ts +77 -67
- package/lib/Defaults/index.js +148 -136
- package/lib/Defaults/phonenumber-mcc.json +223 -223
- package/lib/Signal/WASignalGroup/GroupProtocol.js +1908 -1908
- package/lib/Signal/WASignalGroup/ciphertext-message.d.ts +9 -0
- package/lib/Signal/WASignalGroup/ciphertext-message.js +19 -0
- package/lib/Signal/WASignalGroup/ciphertext_message.js +15 -15
- package/lib/Signal/WASignalGroup/group-session-builder.d.ts +17 -0
- package/lib/Signal/WASignalGroup/group-session-builder.js +72 -0
- package/lib/Signal/WASignalGroup/group.proto +41 -41
- package/lib/Signal/WASignalGroup/group_cipher.d.ts +19 -0
- package/lib/Signal/WASignalGroup/group_cipher.js +101 -110
- package/lib/Signal/WASignalGroup/group_session_builder.js +45 -45
- package/lib/Signal/WASignalGroup/index.d.ts +11 -0
- package/lib/Signal/WASignalGroup/index.js +61 -6
- package/lib/Signal/WASignalGroup/keyhelper.d.ts +16 -0
- package/lib/Signal/WASignalGroup/keyhelper.js +58 -13
- package/lib/Signal/WASignalGroup/protobufs.js +2 -2
- package/lib/Signal/WASignalGroup/queue_job.js +68 -68
- package/lib/Signal/WASignalGroup/readme.md +5 -5
- package/lib/Signal/WASignalGroup/sender-chain-key.d.ts +14 -0
- package/lib/Signal/WASignalGroup/sender-chain-key.js +47 -0
- package/lib/Signal/WASignalGroup/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/WASignalGroup/sender-key-distribution-message.js +71 -0
- package/lib/Signal/WASignalGroup/sender-key-message.d.ts +19 -0
- package/lib/Signal/WASignalGroup/sender-key-message.js +73 -0
- package/lib/Signal/WASignalGroup/sender-key-name.d.ts +19 -0
- package/lib/Signal/WASignalGroup/sender-key-name.js +59 -0
- package/lib/Signal/WASignalGroup/sender-key-record.d.ts +32 -0
- package/lib/Signal/WASignalGroup/sender-key-record.js +58 -0
- package/lib/Signal/WASignalGroup/sender-key-state.d.ts +44 -0
- package/lib/Signal/WASignalGroup/sender-key-state.js +147 -0
- package/lib/Signal/WASignalGroup/sender-message-key.d.ts +11 -0
- package/lib/Signal/WASignalGroup/sender-message-key.js +33 -0
- package/lib/Signal/WASignalGroup/sender_chain_key.js +49 -49
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +77 -77
- package/lib/Signal/WASignalGroup/sender_key_message.js +91 -91
- package/lib/Signal/WASignalGroup/sender_key_name.js +69 -69
- package/lib/Signal/WASignalGroup/sender_key_record.js +55 -55
- package/lib/Signal/WASignalGroup/sender_key_state.js +128 -128
- package/lib/Signal/WASignalGroup/sender_message_key.js +38 -38
- package/lib/Signal/libsignal.d.ts +5 -1
- package/lib/Signal/libsignal.js +390 -161
- package/lib/Signal/lid-mapping.d.ts +28 -0
- package/lib/Signal/lid-mapping.js +184 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -15
- package/lib/Socket/Client/abstract-socket-client.js +13 -13
- package/lib/Socket/Client/index.d.ts +2 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -12
- package/lib/Socket/Client/mobile-socket-client.js +65 -65
- package/lib/Socket/Client/types.d.ts +1 -1
- package/lib/Socket/Client/websocket.d.ts +1 -1
- package/lib/Socket/business.d.ts +6 -6
- package/lib/Socket/business.js +152 -5
- package/lib/Socket/chats.d.ts +3 -4
- package/lib/Socket/chats.js +31 -26
- package/lib/Socket/communities.d.ts +223 -223
- package/lib/Socket/communities.js +432 -432
- package/lib/Socket/groups.d.ts +2 -4
- package/lib/Socket/groups.js +22 -14
- package/lib/Socket/index.d.ts +69 -69
- package/lib/Socket/index.js +3 -2
- package/lib/Socket/messages-recv.d.ts +3 -6
- package/lib/Socket/messages-recv.js +1449 -1707
- package/lib/Socket/messages-send.d.ts +2 -4
- package/lib/Socket/messages-send.js +617 -126
- package/lib/Socket/mex.d.ts +2 -2
- package/lib/Socket/mex.js +46 -46
- package/lib/Socket/newsletter.d.ts +2 -4
- package/lib/Socket/newsletter.js +294 -285
- package/lib/Socket/socket.js +318 -132
- package/lib/Socket/usync.js +3 -3
- package/lib/Store/index.d.ts +4 -4
- package/lib/Store/index.js +23 -23
- package/lib/Store/make-cache-manager-store.d.ts +13 -13
- package/lib/Store/make-cache-manager-store.js +89 -89
- package/lib/Store/make-in-memory-store.d.ts +122 -122
- package/lib/Store/make-in-memory-store.js +428 -428
- package/lib/Store/make-ordered-dictionary.d.ts +11 -11
- package/lib/Store/make-ordered-dictionary.js +85 -85
- package/lib/Store/object-repository.d.ts +9 -9
- package/lib/Store/object-repository.js +30 -30
- package/lib/Types/Auth.d.ts +5 -4
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Bussiness.d.ts +28 -0
- package/lib/Types/Chat.d.ts +13 -8
- package/lib/Types/Contact.d.ts +4 -1
- package/lib/Types/Events.d.ts +13 -16
- package/lib/Types/GroupMetadata.d.ts +1 -1
- package/lib/Types/Message.d.ts +18 -7
- package/lib/Types/Message.js +7 -1
- package/lib/Types/MexUpdates.d.ts +8 -8
- package/lib/Types/MexUpdates.js +17 -17
- package/lib/Types/Newsletter.d.ts +1 -1
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +31 -1
- package/lib/Types/Socket.d.ts +34 -13
- package/lib/Types/State.d.ts +1 -1
- package/lib/Types/USync.d.ts +2 -2
- package/lib/Types/index.d.ts +16 -15
- package/lib/Types/index.js +4 -2
- package/lib/Utils/auth-utils.d.ts +20 -20
- package/lib/Utils/auth-utils.js +527 -204
- package/lib/Utils/baileys-event-stream.d.ts +17 -17
- package/lib/Utils/baileys-event-stream.js +69 -69
- package/lib/Utils/business.d.ts +28 -28
- package/lib/Utils/business.js +254 -254
- package/lib/Utils/chat-utils.d.ts +81 -81
- package/lib/Utils/chat-utils.js +808 -780
- package/lib/Utils/crypto.d.ts +55 -55
- package/lib/Utils/crypto.js +188 -178
- package/lib/Utils/decode-wa-message.d.ts +52 -40
- package/lib/Utils/decode-wa-message.js +322 -252
- package/lib/Utils/event-buffer.d.ts +38 -38
- package/lib/Utils/event-buffer.js +594 -564
- package/lib/Utils/generics.d.ts +131 -129
- package/lib/Utils/generics.js +629 -623
- package/lib/Utils/history.d.ts +22 -22
- package/lib/Utils/history.js +103 -109
- package/lib/Utils/index.d.ts +20 -19
- package/lib/Utils/index.js +39 -38
- package/lib/Utils/link-preview.d.ts +22 -22
- package/lib/Utils/link-preview.js +119 -119
- package/lib/Utils/logger.d.ts +13 -13
- package/lib/Utils/logger.js +7 -7
- package/lib/Utils/lt-hash.d.ts +13 -13
- package/lib/Utils/lt-hash.js +57 -57
- package/lib/Utils/make-mutex.d.ts +8 -8
- package/lib/Utils/make-mutex.js +48 -48
- package/lib/Utils/message-retry-manager.d.ts +88 -0
- package/lib/Utils/message-retry-manager.js +160 -0
- package/lib/Utils/messages-media.d.ts +134 -128
- package/lib/Utils/messages-media.js +868 -805
- package/lib/Utils/messages.d.ts +104 -102
- package/lib/Utils/messages.js +1744 -1578
- package/lib/Utils/noise-handler.d.ts +20 -19
- package/lib/Utils/noise-handler.js +164 -154
- package/lib/Utils/process-message.d.ts +48 -48
- package/lib/Utils/process-message.js +427 -428
- package/lib/Utils/signal.d.ts +41 -41
- package/lib/Utils/signal.js +165 -165
- package/lib/Utils/use-mongo-file-auth-state.d.ts +5 -5
- package/lib/Utils/use-mongo-file-auth-state.js +83 -83
- package/lib/Utils/use-multi-file-auth-state.d.ts +17 -17
- package/lib/Utils/use-multi-file-auth-state.js +237 -237
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -12
- package/lib/Utils/use-single-file-auth-state.js +79 -79
- package/lib/Utils/validate-connection.d.ts +12 -12
- package/lib/Utils/validate-connection.js +219 -186
- package/lib/WABinary/constants.d.ts +29 -29
- package/lib/WABinary/constants.js +1315 -1315
- package/lib/WABinary/decode.d.ts +8 -8
- package/lib/WABinary/decode.js +287 -287
- package/lib/WABinary/encode.d.ts +2 -2
- package/lib/WABinary/encode.js +264 -264
- package/lib/WABinary/generic-utils.d.ts +27 -27
- package/lib/WABinary/generic-utils.js +141 -141
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.js +24 -24
- package/lib/WABinary/jid-utils.d.ts +58 -53
- package/lib/WABinary/jid-utils.js +103 -91
- package/lib/WABinary/types.d.ts +21 -21
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -15
- package/lib/WAM/BinaryInfo.js +16 -16
- package/lib/WAM/constants.d.ts +46 -46
- package/lib/WAM/constants.js +15370 -15370
- package/lib/WAM/encode.d.ts +2 -2
- package/lib/WAM/encode.js +163 -164
- package/lib/WAM/index.d.ts +3 -3
- package/lib/WAM/index.js +22 -22
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +27 -27
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +68 -68
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -8
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +37 -29
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/index.d.ts +6 -6
- package/lib/WAUSync/USyncQuery.d.ts +3 -3
- package/lib/WAUSync/index.d.ts +3 -3
- package/lib/index.d.ts +13 -13
- package/lib/index.js +33 -33
- package/package.json +96 -94
- package/lib/Socket/registration.d.ts +0 -266
- package/lib/Socket/registration.js +0 -166
package/lib/Socket/business.js
CHANGED
|
@@ -2,17 +2,152 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const Utils_1 = require("../Utils")
|
|
6
6
|
const WABinary_1 = require("../WABinary")
|
|
7
|
+
const business_1 = require("../Utils/business")
|
|
7
8
|
const generic_utils_1 = require("../WABinary/generic-utils")
|
|
8
9
|
const messages_recv_1 = require("./messages-recv")
|
|
9
10
|
|
|
10
11
|
const makeBusinessSocket = (config) => {
|
|
11
|
-
const
|
|
12
|
-
const { authState, query, waUploadToServer } =
|
|
12
|
+
const baron = messages_recv_1.makeMessagesRecvSocket(config)
|
|
13
|
+
const { authState, query, waUploadToServer } = baron
|
|
14
|
+
|
|
15
|
+
const updateBussinesProfile = async (args) => {
|
|
16
|
+
const node = []
|
|
17
|
+
const simpleFields = ['address', 'email', 'description']
|
|
18
|
+
|
|
19
|
+
node.push(...simpleFields
|
|
20
|
+
.filter(key => args[key])
|
|
21
|
+
.map(key => ({
|
|
22
|
+
tag: key,
|
|
23
|
+
attrs: {},
|
|
24
|
+
content: args[key]
|
|
25
|
+
})))
|
|
26
|
+
|
|
27
|
+
if (args.websites) {
|
|
28
|
+
|
|
29
|
+
node.push(...args.websites.map(website => ({
|
|
30
|
+
tag: 'website',
|
|
31
|
+
attrs: {},
|
|
32
|
+
content: website
|
|
33
|
+
})))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (args.hours) {
|
|
37
|
+
|
|
38
|
+
node.push({
|
|
39
|
+
tag: 'business_hours',
|
|
40
|
+
attrs: { timezone: args.hours.timezone },
|
|
41
|
+
content: args.hours.days.map(config => {
|
|
42
|
+
const base = {
|
|
43
|
+
tag: 'business_hours_config',
|
|
44
|
+
attrs: { day_of_week: config.day, mode: config.mode }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (config.mode === 'specific_hours') {
|
|
48
|
+
return {
|
|
49
|
+
...base,
|
|
50
|
+
attrs: {
|
|
51
|
+
...base.attrs,
|
|
52
|
+
open_time: config.openTimeInMinutes,
|
|
53
|
+
close_time: config.closeTimeInMinutes
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return base
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const result = await query({
|
|
64
|
+
tag: 'iq',
|
|
65
|
+
attrs: {
|
|
66
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
67
|
+
type: 'set',
|
|
68
|
+
xmlns: 'w:biz'
|
|
69
|
+
},
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
tag: 'business_profile',
|
|
73
|
+
attrs: {
|
|
74
|
+
v: '3',
|
|
75
|
+
mutation_type: 'delta'
|
|
76
|
+
},
|
|
77
|
+
content: node
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return result
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const updateCoverPhoto = async (photo) => {
|
|
86
|
+
const { fileSha256, filePath } = await Utils_1.getRawMediaUploadData(photo, 'biz-cover-photo')
|
|
87
|
+
const fileSha256B64 = fileSha256.toString('base64')
|
|
88
|
+
|
|
89
|
+
const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
|
|
90
|
+
fileEncSha256B64: fileSha256B64,
|
|
91
|
+
mediaType: 'biz-cover-photo'
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
await query({
|
|
95
|
+
tag: 'iq',
|
|
96
|
+
attrs: {
|
|
97
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
98
|
+
type: 'set',
|
|
99
|
+
xmlns: 'w:biz'
|
|
100
|
+
},
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
tag: 'business_profile',
|
|
104
|
+
attrs: {
|
|
105
|
+
v: '3',
|
|
106
|
+
mutation_type: 'delta'
|
|
107
|
+
},
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
tag: 'cover_photo',
|
|
111
|
+
attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return fbid
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const removeCoverPhoto = async (id) => {
|
|
122
|
+
return await query({
|
|
123
|
+
tag: 'iq',
|
|
124
|
+
attrs: {
|
|
125
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
126
|
+
type: 'set',
|
|
127
|
+
xmlns: 'w:biz'
|
|
128
|
+
},
|
|
129
|
+
content: [
|
|
130
|
+
{
|
|
131
|
+
tag: 'business_profile',
|
|
132
|
+
attrs: {
|
|
133
|
+
v: '3',
|
|
134
|
+
mutation_type: 'delta'
|
|
135
|
+
},
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
tag: 'cover_photo',
|
|
139
|
+
attrs: { op: 'delete', id }
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
|
|
13
147
|
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
14
148
|
jid = jid || authState.creds.me?.id
|
|
15
149
|
jid = WABinary_1.jidNormalizedUser(jid)
|
|
150
|
+
|
|
16
151
|
const queryParamNodes = [
|
|
17
152
|
{
|
|
18
153
|
tag: 'limit',
|
|
@@ -30,6 +165,7 @@ const makeBusinessSocket = (config) => {
|
|
|
30
165
|
content: Buffer.from('100')
|
|
31
166
|
},
|
|
32
167
|
]
|
|
168
|
+
|
|
33
169
|
if (cursor) {
|
|
34
170
|
queryParamNodes.push({
|
|
35
171
|
tag: 'after',
|
|
@@ -37,6 +173,7 @@ const makeBusinessSocket = (config) => {
|
|
|
37
173
|
content: cursor
|
|
38
174
|
})
|
|
39
175
|
}
|
|
176
|
+
|
|
40
177
|
const result = await query({
|
|
41
178
|
tag: 'iq',
|
|
42
179
|
attrs: {
|
|
@@ -55,12 +192,14 @@ const makeBusinessSocket = (config) => {
|
|
|
55
192
|
}
|
|
56
193
|
]
|
|
57
194
|
})
|
|
195
|
+
|
|
58
196
|
return business_1.parseCatalogNode(result)
|
|
59
197
|
}
|
|
60
198
|
|
|
61
199
|
const getCollections = async (jid, limit = 51) => {
|
|
62
200
|
jid = jid || authState.creds.me?.id
|
|
63
201
|
jid = WABinary_1.jidNormalizedUser(jid)
|
|
202
|
+
|
|
64
203
|
const result = await query({
|
|
65
204
|
tag: 'iq',
|
|
66
205
|
attrs: {
|
|
@@ -100,6 +239,7 @@ const makeBusinessSocket = (config) => {
|
|
|
100
239
|
}
|
|
101
240
|
]
|
|
102
241
|
})
|
|
242
|
+
|
|
103
243
|
return business_1.parseCollectionsNode(result)
|
|
104
244
|
}
|
|
105
245
|
|
|
@@ -145,12 +285,14 @@ const makeBusinessSocket = (config) => {
|
|
|
145
285
|
}
|
|
146
286
|
]
|
|
147
287
|
})
|
|
288
|
+
|
|
148
289
|
return business_1.parseOrderDetailsNode(result)
|
|
149
290
|
}
|
|
150
291
|
|
|
151
292
|
const productUpdate = async (productId, update) => {
|
|
152
293
|
update = await business_1.uploadingNecessaryImagesOfProduct(update, waUploadToServer)
|
|
153
294
|
const editNode = business_1.toProductNode(productId, update)
|
|
295
|
+
|
|
154
296
|
const result = await query({
|
|
155
297
|
tag: 'iq',
|
|
156
298
|
attrs: {
|
|
@@ -188,6 +330,7 @@ const makeBusinessSocket = (config) => {
|
|
|
188
330
|
create.isHidden = !!create.isHidden
|
|
189
331
|
create = await business_1.uploadingNecessaryImagesOfProduct(create, waUploadToServer)
|
|
190
332
|
const createNode = business_1.toProductNode(undefined, create)
|
|
333
|
+
|
|
191
334
|
const result = await query({
|
|
192
335
|
tag: 'iq',
|
|
193
336
|
attrs: {
|
|
@@ -217,6 +360,7 @@ const makeBusinessSocket = (config) => {
|
|
|
217
360
|
})
|
|
218
361
|
const productCatalogAddNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_add')
|
|
219
362
|
const productNode = generic_utils_1.getBinaryNodeChild(productCatalogAddNode, 'product')
|
|
363
|
+
|
|
220
364
|
return business_1.parseProductNode(productNode)
|
|
221
365
|
}
|
|
222
366
|
|
|
@@ -252,14 +396,17 @@ const makeBusinessSocket = (config) => {
|
|
|
252
396
|
}
|
|
253
397
|
}
|
|
254
398
|
return {
|
|
255
|
-
...
|
|
399
|
+
...baron,
|
|
256
400
|
logger: config.logger,
|
|
257
401
|
getOrderDetails,
|
|
258
402
|
getCatalog,
|
|
259
403
|
getCollections,
|
|
260
404
|
productCreate,
|
|
261
405
|
productDelete,
|
|
262
|
-
productUpdate
|
|
406
|
+
productUpdate,
|
|
407
|
+
updateBussinesProfile,
|
|
408
|
+
updateCoverPhoto,
|
|
409
|
+
removeCoverPhoto
|
|
263
410
|
}
|
|
264
411
|
}
|
|
265
412
|
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Boom } from '@hapi/boom'
|
|
|
2
2
|
import { proto } from '../../WAProto'
|
|
3
3
|
import { BotListInfo, ChatModification, ContactAction, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types'
|
|
4
4
|
import { LabelActionBody } from '../Types/Label'
|
|
5
|
+
import { QuickReplyAction } from '../Types/Bussines'
|
|
5
6
|
import { BinaryNode } from '../WABinary'
|
|
6
7
|
import { USyncQuery } from '../WAUSync'
|
|
7
8
|
|
|
@@ -22,10 +23,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
22
23
|
lid: string
|
|
23
24
|
id: string
|
|
24
25
|
}[] | undefined>
|
|
25
|
-
onWhatsApp: (...jids: string[]) => Promise<{
|
|
26
|
-
jid: string
|
|
27
|
-
exists: unknown
|
|
28
|
-
}[] | undefined>
|
|
29
26
|
fetchBlocklist: () => Promise<string[]>
|
|
30
27
|
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
|
|
31
28
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>
|
|
@@ -58,6 +55,8 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
58
55
|
id: string
|
|
59
56
|
fromMe?: boolean
|
|
60
57
|
}[], star: boolean) => Promise<void>
|
|
58
|
+
addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>
|
|
59
|
+
removeQuickReply: (timestamp: string) => Promise<void>
|
|
61
60
|
addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>
|
|
62
61
|
removeContact: (jid: string) => Promise<void>
|
|
63
62
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>
|
package/lib/Socket/chats.js
CHANGED
|
@@ -15,13 +15,13 @@ const Utils_1 = require("../Utils")
|
|
|
15
15
|
const make_mutex_1 = require("../Utils/make-mutex")
|
|
16
16
|
const WABinary_1 = require("../WABinary")
|
|
17
17
|
const WAUSync_1 = require("../WAUSync")
|
|
18
|
-
const
|
|
18
|
+
const socket_1 = require("./socket")
|
|
19
19
|
const MAX_SYNC_ATTEMPTS = 2
|
|
20
20
|
|
|
21
21
|
const makeChatsSocket = (config) => {
|
|
22
22
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config
|
|
23
|
-
const
|
|
24
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, groupFetchAllParticipating } =
|
|
23
|
+
const baron = socket_1.makeSocket(config)
|
|
24
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, signalRepository, onUnexpectedError, groupFetchAllParticipating } = baron
|
|
25
25
|
|
|
26
26
|
let privacySettings
|
|
27
27
|
let syncState = Types_1.SyncState.Connecting
|
|
@@ -195,28 +195,13 @@ const makeChatsSocket = (config) => {
|
|
|
195
195
|
id: targetJid
|
|
196
196
|
})
|
|
197
197
|
|
|
198
|
-
const result = await
|
|
198
|
+
const result = await baron.executeUSyncQuery(usyncQuery)
|
|
199
199
|
|
|
200
200
|
if (result) {
|
|
201
201
|
return result.list
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
const onWhatsApp = async (...jids) => {
|
|
206
|
-
const usyncQuery = new WAUSync_1.USyncQuery().withContactProtocol().withLIDProtocol()
|
|
207
|
-
|
|
208
|
-
for (const jid of jids) {
|
|
209
|
-
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`
|
|
210
|
-
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone))
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const results = await Neele.executeUSyncQuery(usyncQuery)
|
|
214
|
-
|
|
215
|
-
if (results) {
|
|
216
|
-
return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }))
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
205
|
const fetchStatus = async (...jids) => {
|
|
221
206
|
const usyncQuery = new WAUSync_1.USyncQuery().withStatusProtocol()
|
|
222
207
|
|
|
@@ -224,7 +209,7 @@ const makeChatsSocket = (config) => {
|
|
|
224
209
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid))
|
|
225
210
|
}
|
|
226
211
|
|
|
227
|
-
const result = await
|
|
212
|
+
const result = await baron.executeUSyncQuery(usyncQuery)
|
|
228
213
|
|
|
229
214
|
if (result) {
|
|
230
215
|
return result.list
|
|
@@ -237,7 +222,7 @@ const makeChatsSocket = (config) => {
|
|
|
237
222
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid))
|
|
238
223
|
}
|
|
239
224
|
|
|
240
|
-
const result = await
|
|
225
|
+
const result = await baron.executeUSyncQuery(usyncQuery)
|
|
241
226
|
if (result) {
|
|
242
227
|
return result.list
|
|
243
228
|
}
|
|
@@ -540,7 +525,7 @@ const makeChatsSocket = (config) => {
|
|
|
540
525
|
}
|
|
541
526
|
}
|
|
542
527
|
}
|
|
543
|
-
})
|
|
528
|
+
}, authState?.creds?.me?.id || 'resync-app-state')
|
|
544
529
|
|
|
545
530
|
const { onMutation } = newAppStateChunkHandler(isInitialSync)
|
|
546
531
|
|
|
@@ -735,7 +720,7 @@ const makeChatsSocket = (config) => {
|
|
|
735
720
|
}
|
|
736
721
|
await query(node)
|
|
737
722
|
await authState.keys.set({ 'app-state-sync-version': { [name]: state } })
|
|
738
|
-
})
|
|
723
|
+
}, authState?.creds?.me?.id || 'app-patch')
|
|
739
724
|
})
|
|
740
725
|
|
|
741
726
|
if (config.emitOwnEvents) {
|
|
@@ -901,6 +886,24 @@ const makeChatsSocket = (config) => {
|
|
|
901
886
|
}, jid)
|
|
902
887
|
}
|
|
903
888
|
|
|
889
|
+
/**
|
|
890
|
+
* Add or Edit Quick Reply
|
|
891
|
+
*/
|
|
892
|
+
const addOrEditQuickReply = (quickReply) => {
|
|
893
|
+
return chatModify({
|
|
894
|
+
quickReply
|
|
895
|
+
}, '')
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Remove Quick Reply
|
|
900
|
+
*/
|
|
901
|
+
const removeQuickReply = (timestamp) => {
|
|
902
|
+
return chatModify({
|
|
903
|
+
quickReply: { timestamp, deleted: true }
|
|
904
|
+
}, '')
|
|
905
|
+
}
|
|
906
|
+
|
|
904
907
|
/**
|
|
905
908
|
* queries need to be fired on connection open
|
|
906
909
|
* help ensure parity with WA Web
|
|
@@ -974,6 +977,7 @@ const makeChatsSocket = (config) => {
|
|
|
974
977
|
}
|
|
975
978
|
})(),
|
|
976
979
|
Utils_1.processMessage(msg, {
|
|
980
|
+
signalRepository,
|
|
977
981
|
shouldProcessHistoryMsg,
|
|
978
982
|
placeholderResendCache,
|
|
979
983
|
ev,
|
|
@@ -1063,7 +1067,7 @@ const makeChatsSocket = (config) => {
|
|
|
1063
1067
|
})
|
|
1064
1068
|
|
|
1065
1069
|
return {
|
|
1066
|
-
...
|
|
1070
|
+
...baron,
|
|
1067
1071
|
star,
|
|
1068
1072
|
addOrEditContact,
|
|
1069
1073
|
removeContact,
|
|
@@ -1076,7 +1080,6 @@ const makeChatsSocket = (config) => {
|
|
|
1076
1080
|
presenceSubscribe,
|
|
1077
1081
|
getBotListV2,
|
|
1078
1082
|
getLidUser,
|
|
1079
|
-
onWhatsApp,
|
|
1080
1083
|
fetchBlocklist,
|
|
1081
1084
|
fetchStatus,
|
|
1082
1085
|
fetchDisappearingDuration,
|
|
@@ -1104,7 +1107,9 @@ const makeChatsSocket = (config) => {
|
|
|
1104
1107
|
removeChatLabel,
|
|
1105
1108
|
addMessageLabel,
|
|
1106
1109
|
removeMessageLabel,
|
|
1107
|
-
clearMessage
|
|
1110
|
+
clearMessage,
|
|
1111
|
+
addOrEditQuickReply,
|
|
1112
|
+
removeQuickReply
|
|
1108
1113
|
}
|
|
1109
1114
|
}
|
|
1110
1115
|
|