@areumtecnologia/wasockets 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Socket/chats.js +24 -6
- package/lib/Utils/generics.js +1 -3
- package/lib/Utils/messages-media.js +2 -1
- package/package.json +1 -1
package/lib/Socket/chats.js
CHANGED
|
@@ -928,9 +928,9 @@ const makeChatsSocket = (config) => {
|
|
|
928
928
|
/**
|
|
929
929
|
* Creates a new business label
|
|
930
930
|
*/
|
|
931
|
-
const createLabel = (name, color, predefinedId = 0) => {
|
|
931
|
+
const createLabel = async (name, color, predefinedId = 0) => {
|
|
932
932
|
const id = (Math.floor(Math.random() * 1000000) + 1).toString()
|
|
933
|
-
|
|
933
|
+
await chatModify({
|
|
934
934
|
addLabel: {
|
|
935
935
|
id,
|
|
936
936
|
name,
|
|
@@ -939,13 +939,20 @@ const makeChatsSocket = (config) => {
|
|
|
939
939
|
deleted: false
|
|
940
940
|
}
|
|
941
941
|
}, '')
|
|
942
|
+
return {
|
|
943
|
+
id,
|
|
944
|
+
name,
|
|
945
|
+
color,
|
|
946
|
+
predefinedId,
|
|
947
|
+
deleted: false
|
|
948
|
+
}
|
|
942
949
|
}
|
|
943
950
|
|
|
944
951
|
/**
|
|
945
952
|
* Updates an existing business label
|
|
946
953
|
*/
|
|
947
|
-
const updateLabel = (id, name, color, predefinedId = 0) => {
|
|
948
|
-
|
|
954
|
+
const updateLabel = async (id, name, color, predefinedId = 0) => {
|
|
955
|
+
await chatModify({
|
|
949
956
|
addLabel: {
|
|
950
957
|
id,
|
|
951
958
|
name,
|
|
@@ -954,18 +961,29 @@ const makeChatsSocket = (config) => {
|
|
|
954
961
|
deleted: false
|
|
955
962
|
}
|
|
956
963
|
}, '')
|
|
964
|
+
return {
|
|
965
|
+
id,
|
|
966
|
+
name,
|
|
967
|
+
color,
|
|
968
|
+
predefinedId,
|
|
969
|
+
deleted: false
|
|
970
|
+
}
|
|
957
971
|
}
|
|
958
972
|
|
|
959
973
|
/**
|
|
960
974
|
* Deletes a business label
|
|
961
975
|
*/
|
|
962
|
-
const deleteLabel = (id) => {
|
|
963
|
-
|
|
976
|
+
const deleteLabel = async (id) => {
|
|
977
|
+
await chatModify({
|
|
964
978
|
addLabel: {
|
|
965
979
|
id,
|
|
966
980
|
deleted: true
|
|
967
981
|
}
|
|
968
982
|
}, '')
|
|
983
|
+
return {
|
|
984
|
+
id,
|
|
985
|
+
deleted: true
|
|
986
|
+
}
|
|
969
987
|
}
|
|
970
988
|
|
|
971
989
|
/**
|
package/lib/Utils/generics.js
CHANGED
|
@@ -180,10 +180,8 @@ const generateMessageID = (userId) => {
|
|
|
180
180
|
}
|
|
181
181
|
const random = randomBytes(20)
|
|
182
182
|
random.copy(data, 28)
|
|
183
|
-
// const sha = asciiDecode([ 83, 85, 75, 73 ]);
|
|
184
183
|
const hash = createHash('sha256').update(data).digest()
|
|
185
|
-
|
|
186
|
-
return hash.toString('hex').toUpperCase().substring(0, 16);
|
|
184
|
+
return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 16)
|
|
187
185
|
}
|
|
188
186
|
|
|
189
187
|
// code is inspired by whatsmeow
|
|
@@ -391,7 +391,8 @@ async function generateThumbnail(file, mediaType, options) {
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
const getHttpStream = async (url, options = {}) => {
|
|
394
|
-
const
|
|
394
|
+
const timeout = options.timeoutMs || 120000
|
|
395
|
+
const signal = options.signal || (timeout ? AbortSignal.timeout(timeout) : undefined)
|
|
395
396
|
const response = await fetch(url.toString(), {
|
|
396
397
|
dispatcher: options.dispatcher,
|
|
397
398
|
method: 'GET',
|