@wppconnect/server 1.8.2 → 1.8.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/CHANGELOG.md +11 -108
- package/Dockerfile +2 -2
- package/README.md +2 -2
- package/dist/controller/catalogController.js +47 -16
- package/dist/controller/catalogController.js.map +1 -1
- package/dist/controller/sessionController.js +11 -2
- package/dist/controller/sessionController.js.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/swagger.json +256 -2
- package/dist/util/functions.js +6 -1
- package/dist/util/functions.js.map +1 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,228 +1,131 @@
|
|
|
1
|
-
## 1.8.
|
|
1
|
+
## 1.8.3 (2023-02-03)
|
|
2
2
|
|
|
3
|
+
## 1.8.2 (2023-01-13)
|
|
3
4
|
|
|
4
5
|
### Bug Fixes
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
- Fixed send message to groups (close [#1049](https://github.com/wppconnect-team/wppconnect-server/issues/1049)) ([f8bc6e4](https://github.com/wppconnect-team/wppconnect-server/commit/f8bc6e4ee14b36e266b86bcf9998acf96629019f))
|
|
9
8
|
|
|
10
9
|
## 1.8.1 (2022-12-28)
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
11
|
# 1.8.0 (2022-12-15)
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
13
|
## 1.7.4 (2022-12-12)
|
|
19
14
|
|
|
20
|
-
|
|
21
15
|
### Bug Fixes
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
- Fixed return undefined on sendListMsg ([eb830ce](https://github.com/wppconnect-team/wppconnect-server/commit/eb830cee97384a0c9a84db8abc0d5f75ea688c86))
|
|
26
18
|
|
|
27
19
|
## 1.7.3 (2022-12-03)
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
31
21
|
## 1.7.2 (2022-11-18)
|
|
32
22
|
|
|
33
|
-
|
|
34
23
|
### Bug Fixes
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
- **deps:** update dependency @wppconnect-team/wppconnect to ^1.19.1 ([#988](https://github.com/wppconnect-team/wppconnect-server/issues/988)) ([1c391e0](https://github.com/wppconnect-team/wppconnect-server/commit/1c391e00e65e70356de26b286e423a649f0ef7af))
|
|
39
26
|
|
|
40
27
|
## 1.7.1 (2022-11-02)
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
29
|
# 1.7.0 (2022-11-02)
|
|
45
30
|
|
|
46
|
-
|
|
47
|
-
|
|
48
31
|
## 1.6.4 (2022-10-20)
|
|
49
32
|
|
|
50
|
-
|
|
51
|
-
|
|
52
33
|
## 1.6.3 (2022-10-10)
|
|
53
34
|
|
|
54
|
-
|
|
55
35
|
### Bug Fixes
|
|
56
36
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
- **deps:** update dependency @wppconnect-team/wppconnect to ^1.17.1 ([#931](https://github.com/wppconnect-team/wppconnect-server/issues/931)) ([04326bf](https://github.com/wppconnect-team/wppconnect-server/commit/04326bf1a142d07d8ca63a807211b407023898d1))
|
|
60
38
|
|
|
61
39
|
## 1.6.2 (2022-08-09)
|
|
62
40
|
|
|
63
|
-
|
|
64
41
|
### Bug Fixes
|
|
65
42
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
- **deps:** update dependency @wppconnect-team/wppconnect to ^1.16.1 ([#866](https://github.com/wppconnect-team/wppconnect-server/issues/866)) ([a824339](https://github.com/wppconnect-team/wppconnect-server/commit/a8243392f8daadef5dec2205263d5a44840ae4ef))
|
|
69
44
|
|
|
70
45
|
## 1.6.1 (2022-08-05)
|
|
71
46
|
|
|
72
|
-
|
|
73
47
|
### Bug Fixes
|
|
74
48
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
- **deps:** update dependency @wppconnect-team/wppconnect to ^1.16.0 ([#860](https://github.com/wppconnect-team/wppconnect-server/issues/860)) ([5f72973](https://github.com/wppconnect-team/wppconnect-server/commit/5f72973788d2844d2297acd73b96e76001b70c37))
|
|
78
50
|
|
|
79
51
|
# 1.6.0 (2022-07-20)
|
|
80
52
|
|
|
81
|
-
|
|
82
|
-
|
|
83
53
|
# 1.5.0 (2022-07-12)
|
|
84
54
|
|
|
85
|
-
|
|
86
55
|
### Features
|
|
87
56
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
- Delete all chats close [#483](https://github.com/wppconnect-team/wppconnect-server/issues/483) ([f47a253](https://github.com/wppconnect-team/wppconnect-server/commit/f47a253b1024778f9c3ed5d14a638689be464936))
|
|
91
58
|
|
|
92
59
|
# 1.4.0 (2022-06-29)
|
|
93
60
|
|
|
94
|
-
|
|
95
|
-
|
|
96
61
|
## 1.3.4 (2022-06-20)
|
|
97
62
|
|
|
98
|
-
|
|
99
|
-
|
|
100
63
|
## 1.3.3 (2022-06-01)
|
|
101
64
|
|
|
102
|
-
|
|
103
|
-
|
|
104
65
|
## 1.3.2 (2022-05-31)
|
|
105
66
|
|
|
106
|
-
|
|
107
|
-
|
|
108
67
|
## 1.3.1 (2022-05-10)
|
|
109
68
|
|
|
110
|
-
|
|
111
|
-
|
|
112
69
|
# 1.3.0 (2022-05-10)
|
|
113
70
|
|
|
114
|
-
|
|
115
71
|
### Features
|
|
116
72
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
73
|
+
- Updated all packages ([5e7b9f2](https://github.com/wppconnect-team/wppconnect-server/commit/5e7b9f2240ccc0e44a129296e92dd6fb5393380e))
|
|
120
74
|
|
|
121
75
|
# 1.2.0 (2022-04-25)
|
|
122
76
|
|
|
123
|
-
|
|
124
|
-
|
|
125
77
|
## 1.1.23 (2022-03-13)
|
|
126
78
|
|
|
127
|
-
|
|
128
|
-
|
|
129
79
|
## 1.1.22 (2022-03-07)
|
|
130
80
|
|
|
131
|
-
|
|
132
|
-
|
|
133
81
|
## 1.1.21 (2022-02-24)
|
|
134
82
|
|
|
135
|
-
|
|
136
|
-
|
|
137
83
|
## 1.1.20 (2022-01-23)
|
|
138
84
|
|
|
139
|
-
|
|
140
|
-
|
|
141
85
|
## 1.1.19 (2022-01-21)
|
|
142
86
|
|
|
143
|
-
|
|
144
|
-
|
|
145
87
|
## 1.1.18 (2022-01-17)
|
|
146
88
|
|
|
147
|
-
|
|
148
|
-
|
|
149
89
|
## 1.1.17 (2022-01-16)
|
|
150
90
|
|
|
151
|
-
|
|
152
|
-
|
|
153
91
|
## 1.1.16 (2022-01-14)
|
|
154
92
|
|
|
155
|
-
|
|
156
|
-
|
|
157
93
|
## 1.1.15 (2022-01-09)
|
|
158
94
|
|
|
159
|
-
|
|
160
|
-
|
|
161
95
|
## 1.1.14 (2021-12-21)
|
|
162
96
|
|
|
163
|
-
|
|
164
|
-
|
|
165
97
|
## 1.1.13 (2021-12-09)
|
|
166
98
|
|
|
167
|
-
|
|
168
|
-
|
|
169
99
|
## 1.1.12 (2021-12-09)
|
|
170
100
|
|
|
171
|
-
|
|
172
|
-
|
|
173
101
|
## 1.1.11 (2021-11-16)
|
|
174
102
|
|
|
175
|
-
|
|
176
|
-
|
|
177
103
|
## 1.1.10 (2021-11-12)
|
|
178
104
|
|
|
179
|
-
|
|
180
|
-
|
|
181
105
|
## 1.1.9 (2021-11-08)
|
|
182
106
|
|
|
183
|
-
|
|
184
|
-
|
|
185
107
|
## 1.1.8 (2021-11-08)
|
|
186
108
|
|
|
187
|
-
|
|
188
|
-
|
|
189
109
|
## 1.1.7 (2021-10-21)
|
|
190
110
|
|
|
191
|
-
|
|
192
|
-
|
|
193
111
|
## 1.1.6 (2021-10-13)
|
|
194
112
|
|
|
195
|
-
|
|
196
113
|
### Bug Fixes
|
|
197
114
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
115
|
+
- block/unblock contato. ([9401b16](https://github.com/wppconnect-team/wppconnect-server/commit/9401b168ce08eb62c5ea392db82df34b69753775))
|
|
201
116
|
|
|
202
117
|
## 1.1.5 (2021-10-01)
|
|
203
118
|
|
|
204
|
-
|
|
205
|
-
|
|
206
119
|
## 1.1.4 (2021-09-22)
|
|
207
120
|
|
|
208
|
-
|
|
209
|
-
|
|
210
121
|
## 1.1.3 (2021-08-13)
|
|
211
122
|
|
|
212
|
-
|
|
213
|
-
|
|
214
123
|
## 1.1.2 (2021-08-11)
|
|
215
124
|
|
|
216
|
-
|
|
217
|
-
|
|
218
125
|
## 1.1.1 (2021-08-06)
|
|
219
126
|
|
|
220
|
-
|
|
221
|
-
|
|
222
127
|
# 1.1.0 (2021-08-04)
|
|
223
128
|
|
|
224
|
-
|
|
225
|
-
|
|
226
129
|
## 1.0.3 (2021-07-15)
|
|
227
130
|
|
|
228
131
|
## 1.0.2 (2021-07-14)
|
package/Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:lts-alpine3.16 as base
|
|
2
2
|
WORKDIR /usr/src/wpp-server
|
|
3
3
|
ENV NODE_ENV=production PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
4
4
|
COPY package.json yarn.lock ./
|
|
@@ -22,4 +22,4 @@ RUN yarn cache clean
|
|
|
22
22
|
COPY . .
|
|
23
23
|
COPY --from=build /usr/src/wpp-server/ /usr/src/wpp-server/
|
|
24
24
|
EXPOSE 21465
|
|
25
|
-
ENTRYPOINT ["node", "dist/server.js"]
|
|
25
|
+
ENTRYPOINT ["node", "dist/server.js"]
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@wppconnect/server)
|
|
8
8
|
[](https://isitmaintained.com/project/wppconnect-team/wppconnect-server 'Average time to resolve an issue')
|
|
9
9
|
[](https://isitmaintained.com/badge/open/wppconnect-team/wppconnect-server.svg 'Percentage of issues still open')
|
|
10
|
-
[](https://github.com/wppconnect-team/wppconnect-serer/actions)
|
|
11
11
|
[](https://github.com/wppconnect-team/wppconnect-server/actions/workflows/build.yml)
|
|
12
12
|
[](https://github.com/release-it/release-it)
|
|
13
13
|
|
|
@@ -23,7 +23,7 @@ Wppconnect Server is a ready-to-use API, just download, install, and start using
|
|
|
23
23
|
|
|
24
24
|
[](https://discord.gg/JU5JGGKGNG)
|
|
25
25
|
[](https://t.me/wppconnect)
|
|
26
|
-
[](https://chat.whatsapp.com/
|
|
26
|
+
[](https://chat.whatsapp.com/LJaQu6ZyNvnBPNAVRbX00K)
|
|
27
27
|
[](https://www.youtube.com/c/wppconnect)
|
|
28
28
|
|
|
29
29
|
## Documentations
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.addProductImage = addProductImage;exports.changeProductImage = changeProductImage;exports.createCollection = createCollection;exports.delProducts = delProducts;exports.deleteCollection = deleteCollection;exports.editCollection = editCollection;exports.editProduct = editProduct;exports.getCollections = getCollections;exports.getProductById = getProductById;exports.getProducts = getProducts;exports.removeProductImage = removeProductImage;exports.setProductVisibility = setProductVisibility;exports.updateCartEnabled = updateCartEnabled;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.addProductImage = addProductImage;exports.changeProductImage = changeProductImage;exports.createCollection = createCollection;exports.delProducts = delProducts;exports.deleteCollection = deleteCollection;exports.editCollection = editCollection;exports.editProduct = editProduct;exports.getCollections = getCollections;exports.getProductById = getProductById;exports.getProducts = getProducts;exports.removeProductImage = removeProductImage;exports.sendLinkCatalog = sendLinkCatalog;exports.setProductVisibility = setProductVisibility;exports.updateCartEnabled = updateCartEnabled;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _functions = require("../util/functions"); /*
|
|
2
17
|
* Copyright 2021 WPPConnect Team
|
|
3
18
|
*
|
|
4
19
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -12,20 +27,7 @@
|
|
|
12
27
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
28
|
* See the License for the specific language governing permissions and
|
|
14
29
|
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
async function getProducts(req, res) {
|
|
17
|
-
const { phone, qnt } = req.query;
|
|
18
|
-
if (!phone)
|
|
19
|
-
return res.status(401).send({
|
|
20
|
-
message: 'Please send the contact number you wish to return the products.'
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const result = await req.client.getProducts(phone, qnt);
|
|
25
|
-
res.status(201).json({ status: 'success', response: result });
|
|
26
|
-
} catch (error) {
|
|
27
|
-
res.status(500).json({ status: 'Error', message: 'Error on get products', error: error });
|
|
28
|
-
}
|
|
30
|
+
*/async function getProducts(req, res) {const { phone, qnt } = req.query;if (!phone) return res.status(401).send({ message: 'Please send the contact number you wish to return the products.' });try {const result = await req.client.getProducts(phone, qnt);res.status(201).json({ status: 'success', response: result });} catch (error) {res.status(500).json({ status: 'Error', message: 'Error on get products', error: error });}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
async function getProductById(req, res) {
|
|
@@ -42,6 +44,7 @@ async function getProductById(req, res) {
|
|
|
42
44
|
res.status(500).json({ status: 'Error', message: 'Error on get product', error: error });
|
|
43
45
|
}
|
|
44
46
|
}
|
|
47
|
+
|
|
45
48
|
async function editProduct(req, res) {
|
|
46
49
|
const { id, options } = req.body;
|
|
47
50
|
if (!id || !options)
|
|
@@ -200,10 +203,38 @@ async function updateCartEnabled(req, res) {
|
|
|
200
203
|
});
|
|
201
204
|
|
|
202
205
|
try {
|
|
203
|
-
const result = await req.client.
|
|
206
|
+
const result = await req.client.updateCartEnabled(enabled);
|
|
204
207
|
res.status(201).json({ status: 'success', response: result });
|
|
205
208
|
} catch (error) {
|
|
206
209
|
res.status(500).json({ status: 'Error', message: 'Error on set enabled cart.', error: error });
|
|
207
210
|
}
|
|
208
211
|
}
|
|
212
|
+
|
|
213
|
+
async function sendLinkCatalog(req, res) {
|
|
214
|
+
const { phones, message } = req.body;
|
|
215
|
+
if (!phones)
|
|
216
|
+
return res.status(401).send({
|
|
217
|
+
message: 'phones was not informed'
|
|
218
|
+
});
|
|
219
|
+
const results = [];
|
|
220
|
+
try {
|
|
221
|
+
const session = await req.client.getWid();
|
|
222
|
+
const catalogLink = (0, _functions.createCatalogLink)(session);
|
|
223
|
+
for (const phone of phones) {
|
|
224
|
+
const result = await req.client.sendText(phone, `${message} ${catalogLink}`, {
|
|
225
|
+
useTemplateButtons: true,
|
|
226
|
+
buttons: [
|
|
227
|
+
{
|
|
228
|
+
url: catalogLink,
|
|
229
|
+
text: 'Abrir catálogo'
|
|
230
|
+
}]
|
|
231
|
+
|
|
232
|
+
});
|
|
233
|
+
results.push({ phone, status: result.id });
|
|
234
|
+
}
|
|
235
|
+
return res.status(200).json({ status: 'success', response: results });
|
|
236
|
+
} catch (error) {
|
|
237
|
+
res.status(500).json({ status: 'Error', message: 'Error on set enabled cart.', error: error });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
209
240
|
//# sourceMappingURL=catalogController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogController.js","names":["getProducts","req","res","phone","qnt","query","status","send","message","result","client","json","response","error","getProductById","id","editProduct","options","body","delProducts","changeProductImage","base64","addProductImage","removeProductImage","index","getCollections","max","createCollection","name","products","editCollection","deleteCollection","setProductVisibility","value","updateCartEnabled","enabled"],"sources":["../../src/controller/catalogController.js"],"sourcesContent":["/*\n * Copyright 2021 WPPConnect Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport async function getProducts(req, res) {\n const { phone, qnt } = req.query;\n if (!phone)\n return res.status(401).send({\n message: 'Please send the contact number you wish to return the products.',\n });\n\n try {\n const result = await req.client.getProducts(phone, qnt);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on get products', error: error });\n }\n}\n\nexport async function getProductById(req, res) {\n const { phone, id } = req.query;\n if (!phone || !id)\n return res.status(401).send({\n message: 'Please send the contact number and productId.',\n });\n\n try {\n const result = await req.client.getProductById(phone, id);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on get product', error: error });\n }\n}\nexport async function editProduct(req, res) {\n const { id, options } = req.body;\n if (!id || !options)\n return res.status(401).send({\n message: 'productId or options was not informed',\n });\n\n try {\n const result = await req.client.editProduct(id, options);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on edit product.', error: error });\n }\n}\n\nexport async function delProducts(req, res) {\n const { id } = req.body;\n if (!id)\n return res.status(401).send({\n message: 'products Id was not informed',\n });\n\n try {\n const result = await req.client.delProducts(id);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on delete product.', error: error });\n }\n}\n\nexport async function changeProductImage(req, res) {\n const { id, base64 } = req.body;\n if (!id || !base64)\n return res.status(401).send({\n message: 'productId and base64 was not informed',\n });\n\n try {\n const result = await req.client.changeProductImage(id, base64);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on change product image.', error: error });\n }\n}\n\nexport async function addProductImage(req, res) {\n const { id, base64 } = req.body;\n if (!id || !base64)\n return res.status(401).send({\n message: 'productId and base64 was not informed',\n });\n\n try {\n const result = await req.client.addProductImage(id, base64);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on add product image.', error: error });\n }\n}\n\nexport async function removeProductImage(req, res) {\n const { id, index } = req.body;\n if (!id || !index)\n return res.status(401).send({\n message: 'productId and index image was not informed',\n });\n\n try {\n const result = await req.client.addProductImage(id, index);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on remove product image.', error: error });\n }\n}\n\nexport async function getCollections(req, res) {\n const { phone, qnt, max } = req.query;\n if (!phone)\n return res.status(401).send({\n message: 'phone was not informed',\n });\n\n try {\n const result = await req.client.getCollections(phone, qnt, max);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on get collections.', error: error });\n }\n}\n\nexport async function createCollection(req, res) {\n const { name, products } = req.body;\n if (!name || !products)\n return res.status(401).send({\n message: 'name or products was not informed',\n });\n\n try {\n const result = await req.client.createCollection(name, products);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on create collection.', error: error });\n }\n}\n\nexport async function editCollection(req, res) {\n const { id, options } = req.body;\n if (!id || !options)\n return res.status(401).send({\n message: 'id or options was not informed',\n });\n\n try {\n const result = await req.client.createCollection(id, options);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on edit collection.', error: error });\n }\n}\n\nexport async function deleteCollection(req, res) {\n const { id } = req.body;\n if (!id)\n return res.status(401).send({\n message: 'id was not informed',\n });\n\n try {\n const result = await req.client.deleteCollection(id);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on delete collection.', error: error });\n }\n}\n\nexport async function setProductVisibility(req, res) {\n const { id, value } = req.body;\n if (!id || !value)\n return res.status(401).send({\n message: 'product id or value (false, true) was not informed',\n });\n\n try {\n const result = await req.client.setProductVisibility(id, value);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on set product visibility.', error: error });\n }\n}\n\nexport async function updateCartEnabled(req, res) {\n const { enabled } = req.body;\n if (!enabled)\n return res.status(401).send({\n message: 'enabled (false, true) was not informed',\n });\n\n try {\n const result = await req.client.setProductVisibility(enabled);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on set enabled cart.', error: error });\n }\n}\n"],"mappings":"8mBAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,WAAW,CAACC,GAAG,EAAEC,GAAG,EAAE;EAC1C,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,CAAC,GAAGH,GAAG,CAACI,KAAK;EAChC,IAAI,CAACF,KAAK;EACR,OAAOD,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC;IAC1BC,OAAO,EAAE;EACX,CAAC,CAAC;;EAEJ,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMR,GAAG,CAACS,MAAM,CAACV,WAAW,CAACG,KAAK,EAAEC,GAAG,CAAC;IACvDF,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,SAAS,EAAEM,QAAQ,EAAEH,MAAM,CAAC,CAAC,CAAC;EAC/D,CAAC,CAAC,OAAOI,KAAK,EAAE;IACdX,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,OAAO,EAAEE,OAAO,EAAE,uBAAuB,EAAEK,KAAK,EAAEA,KAAK,CAAC,CAAC,CAAC;EAC3F;AACF;;AAEO,eAAeC,cAAc,CAACb,GAAG,EAAEC,GAAG,EAAE;EAC7C,MAAM,EAAEC,KAAK,EAAEY,EAAE,CAAC,CAAC,GAAGd,GAAG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EAEJ,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMR,GAAG,CAACS,MAAM,CAACsB,oBAAoB,CAACjB,EAAE,EAAEkB,KAAK,CAAC;IAC/D/B,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,SAAS,EAAEM,QAAQ,EAAEH,MAAM,CAAC,CAAC,CAAC;EAC/D,CAAC,CAAC,OAAOI,KAAK,EAAE;IACdX,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,OAAO,EAAEE,OAAO,EAAE,kCAAkC,EAAEK,KAAK,EAAEA,KAAK,CAAC,CAAC,CAAC;EACtG;AACF;;AAEO,eAAeqB,iBAAiB,CAACjC,GAAG,EAAEC,GAAG,EAAE;EAChD,MAAM,EAAEiC,OAAO,CAAC,CAAC,GAAGlC,GAAG,CAACiB,IAAI;EAC5B,IAAI,CAACiB,OAAO;EACV,OAAOjC,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC;IAC1BC,OAAO,EAAE;EACX,CAAC,CAAC;;EAEJ,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMR,GAAG,CAACS,MAAM,CAACsB,oBAAoB,CAACG,OAAO,CAAC;IAC7DjC,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,SAAS,EAAEM,QAAQ,EAAEH,MAAM,CAAC,CAAC,CAAC;EAC/D,CAAC,CAAC,OAAOI,KAAK,EAAE;IACdX,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,OAAO,EAAEE,OAAO,EAAE,4BAA4B,EAAEK,KAAK,EAAEA,KAAK,CAAC,CAAC,CAAC;EAChG;AACF"}
|
|
1
|
+
{"version":3,"file":"catalogController.js","names":["getProducts","req","res","phone","qnt","query","status","send","message","result","client","json","response","error","getProductById","id","editProduct","options","body","delProducts","changeProductImage","base64","addProductImage","removeProductImage","index","getCollections","max","createCollection","name","products","editCollection","deleteCollection","setProductVisibility","value","updateCartEnabled","enabled","sendLinkCatalog","phones","results","session","getWid","catalogLink","createCatalogLink","sendText","useTemplateButtons","buttons","url","text","push"],"sources":["../../src/controller/catalogController.js"],"sourcesContent":["/*\n * Copyright 2021 WPPConnect Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createCatalogLink, groupNameToArray } from '../util/functions';\n\nexport async function getProducts(req, res) {\n const { phone, qnt } = req.query;\n if (!phone)\n return res.status(401).send({\n message: 'Please send the contact number you wish to return the products.',\n });\n\n try {\n const result = await req.client.getProducts(phone, qnt);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on get products', error: error });\n }\n}\n\nexport async function getProductById(req, res) {\n const { phone, id } = req.query;\n if (!phone || !id)\n return res.status(401).send({\n message: 'Please send the contact number and productId.',\n });\n\n try {\n const result = await req.client.getProductById(phone, id);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on get product', error: error });\n }\n}\n\nexport async function editProduct(req, res) {\n const { id, options } = req.body;\n if (!id || !options)\n return res.status(401).send({\n message: 'productId or options was not informed',\n });\n\n try {\n const result = await req.client.editProduct(id, options);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on edit product.', error: error });\n }\n}\n\nexport async function delProducts(req, res) {\n const { id } = req.body;\n if (!id)\n return res.status(401).send({\n message: 'products Id was not informed',\n });\n\n try {\n const result = await req.client.delProducts(id);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on delete product.', error: error });\n }\n}\n\nexport async function changeProductImage(req, res) {\n const { id, base64 } = req.body;\n if (!id || !base64)\n return res.status(401).send({\n message: 'productId and base64 was not informed',\n });\n\n try {\n const result = await req.client.changeProductImage(id, base64);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on change product image.', error: error });\n }\n}\n\nexport async function addProductImage(req, res) {\n const { id, base64 } = req.body;\n if (!id || !base64)\n return res.status(401).send({\n message: 'productId and base64 was not informed',\n });\n\n try {\n const result = await req.client.addProductImage(id, base64);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on add product image.', error: error });\n }\n}\n\nexport async function removeProductImage(req, res) {\n const { id, index } = req.body;\n if (!id || !index)\n return res.status(401).send({\n message: 'productId and index image was not informed',\n });\n\n try {\n const result = await req.client.addProductImage(id, index);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on remove product image.', error: error });\n }\n}\n\nexport async function getCollections(req, res) {\n const { phone, qnt, max } = req.query;\n if (!phone)\n return res.status(401).send({\n message: 'phone was not informed',\n });\n\n try {\n const result = await req.client.getCollections(phone, qnt, max);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on get collections.', error: error });\n }\n}\n\nexport async function createCollection(req, res) {\n const { name, products } = req.body;\n if (!name || !products)\n return res.status(401).send({\n message: 'name or products was not informed',\n });\n\n try {\n const result = await req.client.createCollection(name, products);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on create collection.', error: error });\n }\n}\n\nexport async function editCollection(req, res) {\n const { id, options } = req.body;\n if (!id || !options)\n return res.status(401).send({\n message: 'id or options was not informed',\n });\n\n try {\n const result = await req.client.createCollection(id, options);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on edit collection.', error: error });\n }\n}\n\nexport async function deleteCollection(req, res) {\n const { id } = req.body;\n if (!id)\n return res.status(401).send({\n message: 'id was not informed',\n });\n\n try {\n const result = await req.client.deleteCollection(id);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on delete collection.', error: error });\n }\n}\n\nexport async function setProductVisibility(req, res) {\n const { id, value } = req.body;\n if (!id || !value)\n return res.status(401).send({\n message: 'product id or value (false, true) was not informed',\n });\n\n try {\n const result = await req.client.setProductVisibility(id, value);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on set product visibility.', error: error });\n }\n}\n\nexport async function updateCartEnabled(req, res) {\n const { enabled } = req.body;\n if (!enabled)\n return res.status(401).send({\n message: 'enabled (false, true) was not informed',\n });\n\n try {\n const result = await req.client.updateCartEnabled(enabled);\n res.status(201).json({ status: 'success', response: result });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on set enabled cart.', error: error });\n }\n}\n\nexport async function sendLinkCatalog(req, res) {\n const { phones, message } = req.body;\n if (!phones)\n return res.status(401).send({\n message: 'phones was not informed',\n });\n const results = [];\n try {\n const session = await req.client.getWid();\n const catalogLink = createCatalogLink(session);\n for (const phone of phones) {\n const result = await req.client.sendText(phone, `${message} ${catalogLink}`, {\n useTemplateButtons: true,\n buttons: [\n {\n url: catalogLink,\n text: 'Abrir catálogo',\n },\n ],\n });\n results.push({ phone, status: result.id });\n }\n return res.status(200).json({ status: 'success', response: results });\n } catch (error) {\n res.status(500).json({ status: 'Error', message: 'Error on set enabled cart.', error: error });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,8CAAwE,CAfxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAGO,eAAeA,WAAW,CA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GAAG,MAAMR,GAAG,CAACS,MAAM,CAACiC,QAAQ,CAACxC,KAAK,EAAG,GAAEK,OAAQ,IAAGiC,WAAY,EAAC,EAAE;QAC3EG,kBAAkB,EAAE,IAAI;QACxBC,OAAO,EAAE;QACP;UACEC,GAAG,EAAEL,WAAW;UAChBM,IAAI,EAAE;QACR,CAAC;;MAEL,CAAC,CAAC;MACFT,OAAO,CAACU,IAAI,CAAC,EAAE7C,KAAK,EAAEG,MAAM,EAAEG,MAAM,CAACM,EAAE,CAAC,CAAC,CAAC;IAC5C;IACA,OAAOb,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,SAAS,EAAEM,QAAQ,EAAE0B,OAAO,CAAC,CAAC,CAAC;EACvE,CAAC,CAAC,OAAOzB,KAAK,EAAE;IACdX,GAAG,CAACI,MAAM,CAAC,GAAG,CAAC,CAACK,IAAI,CAAC,EAAEL,MAAM,EAAE,OAAO,EAAEE,OAAO,EAAE,4BAA4B,EAAEK,KAAK,EAAEA,KAAK,CAAC,CAAC,CAAC;EAChG;AACF"}
|
|
@@ -20,7 +20,8 @@ var _getAllTokens = _interopRequireDefault(require("../util/getAllTokens"));
|
|
|
20
20
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
21
|
var _mimeTypes = _interopRequireDefault(require("mime-types"));
|
|
22
22
|
var _package = require("../../package.json");
|
|
23
|
-
var _qrcode = _interopRequireDefault(require("qrcode"));
|
|
23
|
+
var _qrcode = _interopRequireDefault(require("qrcode"));
|
|
24
|
+
var _config = _interopRequireDefault(require("../config.json")); /*
|
|
24
25
|
* Copyright 2021 WPPConnect Team
|
|
25
26
|
*
|
|
26
27
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -154,13 +155,21 @@ async function startSession(req, res) {
|
|
|
154
155
|
|
|
155
156
|
async function closeSession(req, res) {
|
|
156
157
|
const session = req.session;
|
|
158
|
+
const { clearSession = true } = req.body;
|
|
157
159
|
try {
|
|
158
160
|
if (_sessionUtil.clientsArray[session].status === null) {
|
|
159
161
|
return await res.status(200).json({ status: true, message: 'Session successfully closed' });
|
|
160
162
|
} else {
|
|
161
163
|
_sessionUtil.clientsArray[session] = { status: null };
|
|
162
|
-
await req.client.close();
|
|
163
164
|
|
|
165
|
+
if (clearSession) {
|
|
166
|
+
let sessionFolder = `${_config.default.customUserDataDir}/${session}`;
|
|
167
|
+
if (_fs.default.existsSync(sessionFolder)) {
|
|
168
|
+
console.log('Deletando pasta: ' + sessionFolder);
|
|
169
|
+
_fs.default.rmdirSync(sessionFolder, { recursive: true });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
await req.client.close();
|
|
164
173
|
req.io.emit('whatsapp-status', false);
|
|
165
174
|
(0, _functions.callWebHook)(req.client, req, 'closesession', {
|
|
166
175
|
message: `Session: ${session} disconnected`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionController.js","names":["SessionUtil","CreateSessionUtil","downloadFileFunction","message","client","logger","buffer","decryptFile","filename","t","fs","existsSync","result","type","mime","extension","mimetype","writeFile","err","error","e","warn","downloadMedia","download","path","replace","startAllSessions","req","res","secretkey","params","authorization","token","headers","tokenDecrypt","undefined","split","allSessions","getAllTokens","serverOptions","secretKey","status","json","response","map","session","util","opendata","showAllSessions","arr","Object","keys","clientsArray","forEach","item","push","startSession","waitQrCode","body","getSessionState","closeSession","close","io","emit","callWebHook","connected","logOutSession","logout","checkConnectionSession","isConnected","downloadMediaByMessage","messageId","isMedia","getMessageById","isMMS","base64","toString","getMediaByMessage","ex","qr","urlcode","QRCode","toDataURL","qrcode","version","getQrCode","img","Buffer","from","writeHead","length","end","killServiceWorker","restartService","subscribePresence","phone","isGroup","all","contacts","groups","getAllGroups","p","id","_serialized","chats","getAllContacts","c","contato","contactToArray"],"sources":["../../src/controller/sessionController.js"],"sourcesContent":["/*\n * Copyright 2021 WPPConnect Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { clientsArray } from '../util/sessionUtil';\nimport { callWebHook, contactToArray } from '../util/functions';\nimport CreateSessionUtil from '../util/createSessionUtil';\nimport getAllTokens from '../util/getAllTokens';\nimport fs from 'fs';\nimport mime from 'mime-types';\nimport { version } from '../../package.json';\nimport QRCode from 'qrcode';\n\nconst SessionUtil = new CreateSessionUtil();\n\nasync function downloadFileFunction(message, client, logger) {\n try {\n const buffer = await client.decryptFile(message);\n\n let filename = `./WhatsAppImages/file${message.t}`;\n if (!fs.existsSync(filename)) {\n let result = '';\n if (message.type === 'ptt') {\n result = `${filename}.oga`;\n } else {\n result = `${filename}.${mime.extension(message.mimetype)}`;\n }\n\n await fs.writeFile(result, buffer, (err) => {\n if (err) {\n logger.error(err);\n }\n });\n\n return result;\n } else {\n return `${filename}.${mime.extension(message.mimetype)}`;\n }\n } catch (e) {\n logger.error(e);\n logger.warn('Erro ao descriptografar a midia, tentando fazer o download direto...');\n try {\n const buffer = await client.downloadMedia(message);\n const filename = `./WhatsAppImages/file${message.t}`;\n if (!fs.existsSync(filename)) {\n let result = '';\n if (message.type === 'ptt') {\n result = `${filename}.oga`;\n } else {\n result = `${filename}.${mime.extension(message.mimetype)}`;\n }\n\n await fs.writeFile(result, buffer, (err) => {\n if (err) {\n logger.error(err);\n }\n });\n\n return result;\n } else {\n return `${filename}.${mime.extension(message.mimetype)}`;\n }\n } catch (e) {\n logger.error(e);\n logger.warn('Não foi possível baixar a mídia...');\n }\n }\n}\n\nexport async function download(message, client, logger) {\n try {\n const path = await downloadFileFunction(message, client, logger);\n return path.replace('./', '');\n } catch (e) {\n logger.error(e);\n }\n}\n\nexport async function startAllSessions(req, res) {\n const { secretkey } = req.params;\n const { authorization: token } = req.headers;\n\n let tokenDecrypt = '';\n\n if (secretkey === undefined) {\n tokenDecrypt = token.split(' ')[0];\n } else {\n tokenDecrypt = secretkey;\n }\n\n const allSessions = await getAllTokens(req);\n\n if (tokenDecrypt !== req.serverOptions.secretKey) {\n return res.status(400).json({\n response: 'error',\n message: 'The token is incorrect',\n });\n }\n\n allSessions.map(async (session) => {\n const util = new CreateSessionUtil();\n await util.opendata(req, session);\n });\n\n return await res.status(201).json({ status: 'success', message: 'Starting all sessions' });\n}\n\nexport async function showAllSessions(req, res) {\n const { secretkey } = req.params;\n const { authorization: token } = req.headers;\n\n let tokenDecrypt = '';\n\n if (secretkey === undefined) {\n tokenDecrypt = token.split(' ')[0];\n } else {\n tokenDecrypt = secretkey;\n }\n\n const arr = [];\n\n if (tokenDecrypt !== req.serverOptions.secretKey) {\n return res.status(400).json({\n response: false,\n message: 'The token is incorrect',\n });\n }\n\n Object.keys(clientsArray).forEach((item) => {\n arr.push({ session: item });\n });\n\n return res.status(200).json({ response: arr });\n}\n\nexport async function startSession(req, res) {\n const session = req.session;\n const { waitQrCode = false } = req.body;\n\n await getSessionState(req, res);\n await SessionUtil.opendata(req, session, waitQrCode ? res : null);\n}\n\nexport async function closeSession(req, res) {\n const session = req.session;\n try {\n if (clientsArray[session].status === null) {\n return await res.status(200).json({ status: true, message: 'Session successfully closed' });\n } else {\n clientsArray[session] = { status: null };\n await req.client.close();\n\n req.io.emit('whatsapp-status', false);\n callWebHook(req.client, req, 'closesession', {\n message: `Session: ${session} disconnected`,\n connected: false,\n });\n\n return await res.status(200).json({ status: true, message: 'Session successfully closed' });\n }\n } catch (error) {\n req.logger.error(error);\n return await res.status(500).json({ status: false, message: 'Error closing session', error });\n }\n}\n\nexport async function logOutSession(req, res) {\n try {\n const session = req.session;\n await req.client.logout();\n\n req.io.emit('whatsapp-status', false);\n callWebHook(req.client, req, 'logoutsession', {\n message: `Session: ${session} logged out`,\n connected: false,\n });\n\n return await res.status(200).json({ status: true, message: 'Session successfully closed' });\n } catch (error) {\n req.logger.error(error);\n return await res.status(500).json({ status: false, message: 'Error closing session', error });\n }\n}\n\nexport async function checkConnectionSession(req, res) {\n try {\n await req.client.isConnected();\n\n return res.status(200).json({ status: true, message: 'Connected' });\n } catch (error) {\n return res.status(200).json({ status: false, message: 'Disconnected' });\n }\n}\n\nexport async function downloadMediaByMessage(req, res) {\n const client = req.client;\n const { messageId } = req.body;\n\n let message;\n\n try {\n if (!messageId.isMedia || !messageId.type) {\n message = await client.getMessageById(messageId);\n } else {\n message = messageId;\n }\n\n if (!message)\n return res.status(400).json({\n status: 'error',\n message: 'Message not found',\n });\n\n if (!(message['mimetype'] || message.isMedia || message.isMMS))\n return res.status(400).json({\n status: 'error',\n message: 'Message does not contain media',\n });\n\n const buffer = await client.decryptFile(message);\n\n return res.status(200).json({ base64: buffer.toString('base64'), mimetype: message.mimetype });\n } catch (e) {\n req.logger.error(e);\n return res.status(400).json({\n status: 'error',\n message: 'Decrypt file error',\n error: e,\n });\n }\n}\n\nexport async function getMediaByMessage(req, res) {\n const client = req.client;\n const { messageId } = req.params;\n\n try {\n const message = await client.getMessageById(messageId);\n\n if (!message)\n return res.status(400).json({\n status: 'error',\n message: 'Message not found',\n });\n\n if (!(message['mimetype'] || message.isMedia || message.isMMS))\n return res.status(400).json({\n status: 'error',\n message: 'Message does not contain media',\n });\n\n const buffer = await client.decryptFile(message);\n\n return res.status(200).json({ base64: buffer.toString('base64'), mimetype: message.mimetype });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'The session is not active', error: ex });\n }\n}\n\nexport async function getSessionState(req, res) {\n try {\n const { waitQrCode = false } = req.body;\n const client = req.client;\n const qr = client?.urlcode != null && client?.urlcode != '' ? await QRCode.toDataURL(client.urlcode) : null;\n\n if ((client == null || client.status == null) && !waitQrCode)\n return res.status(200).json({ status: 'CLOSED', qrcode: null });\n else if (client != null)\n return res.status(200).json({\n status: client.status,\n qrcode: qr,\n urlcode: client.urlcode,\n version: version,\n });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'The session is not active', error: ex });\n }\n}\n\nexport async function getQrCode(req, res) {\n try {\n if (req.client.urlcode) {\n const qr = req.client.urlcode ? await QRCode.toDataURL(req.client.urlcode) : null;\n const img = Buffer.from(qr.replace(/^data:image\\/(png|jpeg|jpg);base64,/, ''), 'base64');\n\n res.writeHead(200, {\n 'Content-Type': 'image/png',\n 'Content-Length': img.length,\n });\n res.end(img);\n } else {\n return res.status(200).json({ status: req.client.status, message: 'QRCode is not available...' });\n }\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'Error retrieving QRCode', error: ex });\n }\n}\n\nexport async function killServiceWorker(req, res) {\n try {\n return res.status(200).json({ status: 'success', response: req.client.killServiceWorker() });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'The session is not active', error: ex });\n }\n}\n\nexport async function restartService(req, res) {\n try {\n return res.status(200).json({ status: 'success', response: req.client.restartService() });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', response: { message: 'The session is not active', error: ex } });\n }\n}\n\nexport async function subscribePresence(req, res) {\n try {\n const { phone, isGroup = false, all = false } = req.body;\n\n if (all) {\n let contacts;\n if (isGroup) {\n const groups = await req.client.getAllGroups(false);\n contacts = groups.map((p) => p.id._serialized);\n } else {\n const chats = await req.client.getAllContacts();\n contacts = chats.map((c) => c.id._serialized);\n }\n await req.client.subscribePresence(contacts);\n } else\n for (const contato of contactToArray(phone, isGroup)) {\n await req.client.subscribePresence(contato);\n }\n\n return await res.status(200).json({ status: 'success', response: { message: 'Subscribe presence executed' } });\n } catch (error) {\n return await res.status(500).json({ status: 'error', message: 'Error on subscribe presence', error: error });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wDAA4B,CAtB5B;AACA;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CAAC;IAC7C;;IAEF,OAAO,MAAM/E,GAAG,CAACa,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,EAAED,MAAM,EAAE,SAAS,EAAEE,QAAQ,EAAE,EAAExC,OAAO,EAAE,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;EAChH,CAAC,CAAC,OAAOgB,KAAK,EAAE;IACd,OAAO,MAAMS,GAAG,CAACa,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,EAAED,MAAM,EAAE,OAAO,EAAEtC,OAAO,EAAE,6BAA6B,EAAEgB,KAAK,EAAEA,KAAK,CAAC,CAAC,CAAC;EAC9G;AACF"}
|
|
1
|
+
{"version":3,"file":"sessionController.js","names":["SessionUtil","CreateSessionUtil","downloadFileFunction","message","client","logger","buffer","decryptFile","filename","t","fs","existsSync","result","type","mime","extension","mimetype","writeFile","err","error","e","warn","downloadMedia","download","path","replace","startAllSessions","req","res","secretkey","params","authorization","token","headers","tokenDecrypt","undefined","split","allSessions","getAllTokens","serverOptions","secretKey","status","json","response","map","session","util","opendata","showAllSessions","arr","Object","keys","clientsArray","forEach","item","push","startSession","waitQrCode","body","getSessionState","closeSession","clearSession","sessionFolder","config","customUserDataDir","console","log","rmdirSync","recursive","close","io","emit","callWebHook","connected","logOutSession","logout","checkConnectionSession","isConnected","downloadMediaByMessage","messageId","isMedia","getMessageById","isMMS","base64","toString","getMediaByMessage","ex","qr","urlcode","QRCode","toDataURL","qrcode","version","getQrCode","img","Buffer","from","writeHead","length","end","killServiceWorker","restartService","subscribePresence","phone","isGroup","all","contacts","groups","getAllGroups","p","id","_serialized","chats","getAllContacts","c","contato","contactToArray"],"sources":["../../src/controller/sessionController.js"],"sourcesContent":["/*\n * Copyright 2021 WPPConnect Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { clientsArray } from '../util/sessionUtil';\nimport { callWebHook, contactToArray } from '../util/functions';\nimport CreateSessionUtil from '../util/createSessionUtil';\nimport getAllTokens from '../util/getAllTokens';\nimport fs from 'fs';\nimport mime from 'mime-types';\nimport { version } from '../../package.json';\nimport QRCode from 'qrcode';\nimport config from '../config.json';\n\nconst SessionUtil = new CreateSessionUtil();\n\nasync function downloadFileFunction(message, client, logger) {\n try {\n const buffer = await client.decryptFile(message);\n\n let filename = `./WhatsAppImages/file${message.t}`;\n if (!fs.existsSync(filename)) {\n let result = '';\n if (message.type === 'ptt') {\n result = `${filename}.oga`;\n } else {\n result = `${filename}.${mime.extension(message.mimetype)}`;\n }\n\n await fs.writeFile(result, buffer, (err) => {\n if (err) {\n logger.error(err);\n }\n });\n\n return result;\n } else {\n return `${filename}.${mime.extension(message.mimetype)}`;\n }\n } catch (e) {\n logger.error(e);\n logger.warn('Erro ao descriptografar a midia, tentando fazer o download direto...');\n try {\n const buffer = await client.downloadMedia(message);\n const filename = `./WhatsAppImages/file${message.t}`;\n if (!fs.existsSync(filename)) {\n let result = '';\n if (message.type === 'ptt') {\n result = `${filename}.oga`;\n } else {\n result = `${filename}.${mime.extension(message.mimetype)}`;\n }\n\n await fs.writeFile(result, buffer, (err) => {\n if (err) {\n logger.error(err);\n }\n });\n\n return result;\n } else {\n return `${filename}.${mime.extension(message.mimetype)}`;\n }\n } catch (e) {\n logger.error(e);\n logger.warn('Não foi possível baixar a mídia...');\n }\n }\n}\n\nexport async function download(message, client, logger) {\n try {\n const path = await downloadFileFunction(message, client, logger);\n return path.replace('./', '');\n } catch (e) {\n logger.error(e);\n }\n}\n\nexport async function startAllSessions(req, res) {\n const { secretkey } = req.params;\n const { authorization: token } = req.headers;\n\n let tokenDecrypt = '';\n\n if (secretkey === undefined) {\n tokenDecrypt = token.split(' ')[0];\n } else {\n tokenDecrypt = secretkey;\n }\n\n const allSessions = await getAllTokens(req);\n\n if (tokenDecrypt !== req.serverOptions.secretKey) {\n return res.status(400).json({\n response: 'error',\n message: 'The token is incorrect',\n });\n }\n\n allSessions.map(async (session) => {\n const util = new CreateSessionUtil();\n await util.opendata(req, session);\n });\n\n return await res.status(201).json({ status: 'success', message: 'Starting all sessions' });\n}\n\nexport async function showAllSessions(req, res) {\n const { secretkey } = req.params;\n const { authorization: token } = req.headers;\n\n let tokenDecrypt = '';\n\n if (secretkey === undefined) {\n tokenDecrypt = token.split(' ')[0];\n } else {\n tokenDecrypt = secretkey;\n }\n\n const arr = [];\n\n if (tokenDecrypt !== req.serverOptions.secretKey) {\n return res.status(400).json({\n response: false,\n message: 'The token is incorrect',\n });\n }\n\n Object.keys(clientsArray).forEach((item) => {\n arr.push({ session: item });\n });\n\n return res.status(200).json({ response: arr });\n}\n\nexport async function startSession(req, res) {\n const session = req.session;\n const { waitQrCode = false } = req.body;\n\n await getSessionState(req, res);\n await SessionUtil.opendata(req, session, waitQrCode ? res : null);\n}\n\nexport async function closeSession(req, res) {\n const session = req.session;\n const { clearSession = true } = req.body;\n try {\n if (clientsArray[session].status === null) {\n return await res.status(200).json({ status: true, message: 'Session successfully closed' });\n } else {\n clientsArray[session] = { status: null };\n\n if (clearSession) {\n let sessionFolder = `${config.customUserDataDir}/${session}`;\n if (fs.existsSync(sessionFolder)) {\n console.log('Deletando pasta: ' + sessionFolder);\n fs.rmdirSync(sessionFolder, { recursive: true });\n }\n }\n await req.client.close();\n req.io.emit('whatsapp-status', false);\n callWebHook(req.client, req, 'closesession', {\n message: `Session: ${session} disconnected`,\n connected: false,\n });\n\n return await res.status(200).json({ status: true, message: 'Session successfully closed' });\n }\n } catch (error) {\n req.logger.error(error);\n return await res.status(500).json({ status: false, message: 'Error closing session', error });\n }\n}\n\nexport async function logOutSession(req, res) {\n try {\n const session = req.session;\n await req.client.logout();\n\n req.io.emit('whatsapp-status', false);\n callWebHook(req.client, req, 'logoutsession', {\n message: `Session: ${session} logged out`,\n connected: false,\n });\n\n return await res.status(200).json({ status: true, message: 'Session successfully closed' });\n } catch (error) {\n req.logger.error(error);\n return await res.status(500).json({ status: false, message: 'Error closing session', error });\n }\n}\n\nexport async function checkConnectionSession(req, res) {\n try {\n await req.client.isConnected();\n\n return res.status(200).json({ status: true, message: 'Connected' });\n } catch (error) {\n return res.status(200).json({ status: false, message: 'Disconnected' });\n }\n}\n\nexport async function downloadMediaByMessage(req, res) {\n const client = req.client;\n const { messageId } = req.body;\n\n let message;\n\n try {\n if (!messageId.isMedia || !messageId.type) {\n message = await client.getMessageById(messageId);\n } else {\n message = messageId;\n }\n\n if (!message)\n return res.status(400).json({\n status: 'error',\n message: 'Message not found',\n });\n\n if (!(message['mimetype'] || message.isMedia || message.isMMS))\n return res.status(400).json({\n status: 'error',\n message: 'Message does not contain media',\n });\n\n const buffer = await client.decryptFile(message);\n\n return res.status(200).json({ base64: buffer.toString('base64'), mimetype: message.mimetype });\n } catch (e) {\n req.logger.error(e);\n return res.status(400).json({\n status: 'error',\n message: 'Decrypt file error',\n error: e,\n });\n }\n}\n\nexport async function getMediaByMessage(req, res) {\n const client = req.client;\n const { messageId } = req.params;\n\n try {\n const message = await client.getMessageById(messageId);\n\n if (!message)\n return res.status(400).json({\n status: 'error',\n message: 'Message not found',\n });\n\n if (!(message['mimetype'] || message.isMedia || message.isMMS))\n return res.status(400).json({\n status: 'error',\n message: 'Message does not contain media',\n });\n\n const buffer = await client.decryptFile(message);\n\n return res.status(200).json({ base64: buffer.toString('base64'), mimetype: message.mimetype });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'The session is not active', error: ex });\n }\n}\n\nexport async function getSessionState(req, res) {\n try {\n const { waitQrCode = false } = req.body;\n const client = req.client;\n const qr = client?.urlcode != null && client?.urlcode != '' ? await QRCode.toDataURL(client.urlcode) : null;\n\n if ((client == null || client.status == null) && !waitQrCode)\n return res.status(200).json({ status: 'CLOSED', qrcode: null });\n else if (client != null)\n return res.status(200).json({\n status: client.status,\n qrcode: qr,\n urlcode: client.urlcode,\n version: version,\n });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'The session is not active', error: ex });\n }\n}\n\nexport async function getQrCode(req, res) {\n try {\n if (req.client.urlcode) {\n const qr = req.client.urlcode ? await QRCode.toDataURL(req.client.urlcode) : null;\n const img = Buffer.from(qr.replace(/^data:image\\/(png|jpeg|jpg);base64,/, ''), 'base64');\n\n res.writeHead(200, {\n 'Content-Type': 'image/png',\n 'Content-Length': img.length,\n });\n res.end(img);\n } else {\n return res.status(200).json({ status: req.client.status, message: 'QRCode is not available...' });\n }\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'Error retrieving QRCode', error: ex });\n }\n}\n\nexport async function killServiceWorker(req, res) {\n try {\n return res.status(200).json({ status: 'success', response: req.client.killServiceWorker() });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', message: 'The session is not active', error: ex });\n }\n}\n\nexport async function restartService(req, res) {\n try {\n return res.status(200).json({ status: 'success', response: req.client.restartService() });\n } catch (ex) {\n req.logger.error(ex);\n return res.status(500).json({ status: 'error', response: { message: 'The session is not active', error: ex } });\n }\n}\n\nexport async function subscribePresence(req, res) {\n try {\n const { phone, isGroup = false, all = false } = req.body;\n\n if (all) {\n let contacts;\n if (isGroup) {\n const groups = await req.client.getAllGroups(false);\n contacts = groups.map((p) => p.id._serialized);\n } else {\n const chats = await req.client.getAllContacts();\n contacts = chats.map((c) => c.id._serialized);\n }\n await req.client.subscribePresence(contacts);\n } else\n for (const contato of contactToArray(phone, isGroup)) {\n await req.client.subscribePresence(contato);\n }\n\n return await res.status(200).json({ status: 'success', response: { message: 'Subscribe presence executed' } });\n } catch (error) {\n return await res.status(500).json({ status: 'error', message: 'Error on subscribe presence', error: error });\n }\n}\n"],"mappings":";;;;;;;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iE,CAAC,KAAKA,CAAC,CAACC,EAAE,CAACC,WAAW,CAAC;MAChD,CAAC,MAAM;QACL,MAAMC,KAAK,GAAG,MAAMrF,GAAG,CAACvB,MAAM,CAAC6G,cAAc,EAAE;QAC/CP,QAAQ,GAAGM,KAAK,CAACpE,GAAG,CAAC,CAACsE,CAAC,KAAKA,CAAC,CAACJ,EAAE,CAACC,WAAW,CAAC;MAC/C;MACA,MAAMpF,GAAG,CAACvB,MAAM,CAACkG,iBAAiB,CAACI,QAAQ,CAAC;IAC9C,CAAC;IACC,KAAK,MAAMS,OAAO,IAAI,IAAAC,yBAAc,EAACb,KAAK,EAAEC,OAAO,CAAC,EAAE;MACpD,MAAM7E,GAAG,CAACvB,MAAM,CAACkG,iBAAiB,CAACa,OAAO,CAAC;IAC7C;;IAEF,OAAO,MAAMvF,GAAG,CAACa,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,EAAED,MAAM,EAAE,SAAS,EAAEE,QAAQ,EAAE,EAAExC,OAAO,EAAE,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;EAChH,CAAC,CAAC,OAAOgB,KAAK,EAAE;IACd,OAAO,MAAMS,GAAG,CAACa,MAAM,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,EAAED,MAAM,EAAE,OAAO,EAAEtC,OAAO,EAAE,6BAA6B,EAAEgB,KAAK,EAAEA,KAAK,CAAC,CAAC,CAAC;EAC9G;AACF"}
|
package/dist/routes/index.js
CHANGED
|
@@ -215,6 +215,7 @@ routes.get('/api/:session/get-collections', _auth.default, _statusConnection.def
|
|
|
215
215
|
routes.post('/api/:session/create-collection', _auth.default, _statusConnection.default, CatalogController.createCollection);
|
|
216
216
|
routes.post('/api/:session/edit-collection', _auth.default, _statusConnection.default, CatalogController.editCollection);
|
|
217
217
|
routes.post('/api/:session/del-collection', _auth.default, _statusConnection.default, CatalogController.deleteCollection);
|
|
218
|
+
routes.post('/api/:session/send-link-catalog', _auth.default, _statusConnection.default, CatalogController.sendLinkCatalog);
|
|
218
219
|
routes.post(
|
|
219
220
|
'/api/:session/set-product-visibility',
|
|
220
221
|
_auth.default,
|