webfast 0.1.67 → 0.1.69
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/app/content/js/webfast.js +20 -5
- package/modules/data/mongo/find.js +11 -10
- package/package.json +1 -1
@@ -115,6 +115,7 @@ if (telegram.initData == ``) {
|
|
115
115
|
|
116
116
|
const socketURL = `wss://${webfastSocket.replace(`https://`,``)}socket.io/?qbt=${setData}`;
|
117
117
|
|
118
|
+
let countedError = 0;
|
118
119
|
// Assuming you have a variable `socketURL` containing your WebSocket URL
|
119
120
|
web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
120
121
|
web.fast.createWebSocket = function(socketURL, maxRetries, retries) {
|
@@ -134,7 +135,16 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
134
135
|
const type = jQuery(this).attr(`webfast-get`);
|
135
136
|
let id = jQuery(this).attr(`id`);
|
136
137
|
if (id == undefined) {
|
137
|
-
|
138
|
+
var generateRandomId = async function(length) {
|
139
|
+
var result = '';
|
140
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
141
|
+
var charactersLength = characters.length;
|
142
|
+
for (var i = 0; i < length; i++) {
|
143
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
144
|
+
}
|
145
|
+
return result;
|
146
|
+
};
|
147
|
+
id = await generateRandomId(8); // Generate a random ID of length 8
|
138
148
|
}
|
139
149
|
arraySend.push({
|
140
150
|
id : id,
|
@@ -143,11 +153,16 @@ web.fast.connectWebSocket = function(socketURL,maxRetries = 40, retries = 0) {
|
|
143
153
|
})
|
144
154
|
console.log(`Send Array`,arraySend);
|
145
155
|
web.fast.tools.on.connect(arraySend);
|
146
|
-
|
147
|
-
|
148
|
-
|
156
|
+
} else {
|
157
|
+
if (countedError < 3) {
|
158
|
+
console.error(`Tried 10 times`);
|
159
|
+
} else {
|
160
|
+
console.error(`Try again`);
|
161
|
+
throw new Error(`error some send`);
|
162
|
+
}
|
163
|
+
|
164
|
+
}
|
149
165
|
} catch (err) {
|
150
|
-
console.error(`Try again`);
|
151
166
|
setTimeout(function(){
|
152
167
|
arraySend();
|
153
168
|
},200);
|
@@ -11,15 +11,6 @@ module.exports = async function(db,collection,query,one = false,array) {
|
|
11
11
|
process.exit(1);
|
12
12
|
}
|
13
13
|
|
14
|
-
function routeExists(path) {
|
15
|
-
return program.express.app._router.stack.some(layer => {
|
16
|
-
if (layer.route) {
|
17
|
-
return layer.route.path === path;
|
18
|
-
}
|
19
|
-
return false;
|
20
|
-
});
|
21
|
-
}
|
22
|
-
|
23
14
|
// Define the MongoDB URI
|
24
15
|
const uri = process.env.mongo;
|
25
16
|
|
@@ -53,6 +44,16 @@ module.exports = async function(db,collection,query,one = false,array) {
|
|
53
44
|
// Process the result
|
54
45
|
console.log('Query result:', result);
|
55
46
|
|
47
|
+
|
48
|
+
async function routeExists(path) {
|
49
|
+
return program.express.app._router.stack.some(layer => {
|
50
|
+
if (layer.route) {
|
51
|
+
return layer.route.path === path;
|
52
|
+
}
|
53
|
+
return false;
|
54
|
+
});
|
55
|
+
}
|
56
|
+
|
56
57
|
// Check if profile image to get it from db
|
57
58
|
if (result.profileImage != undefined && array.image == true) {
|
58
59
|
const profileImage = await program.modules.data.file.downloadBuffer(result.profileImage,process.env.dbName);
|
@@ -129,6 +130,6 @@ module.exports = async function(db,collection,query,one = false,array) {
|
|
129
130
|
}
|
130
131
|
|
131
132
|
// Execute the main function
|
132
|
-
await main().catch(console.error);
|
133
|
+
return await main().catch(console.error);
|
133
134
|
|
134
135
|
}
|