mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
More intermediary work
This commit is contained in:
@@ -4,8 +4,9 @@ var db = require(pathThumbnails + "/handlers/db.js");
|
||||
var find = require(pathThumbnails + "/handlers/dbFunctions/find.js");
|
||||
var create = require(pathThumbnails + "/handlers/dbFunctions/create.js");
|
||||
var insert = require(pathThumbnails + "/handlers/dbFunctions/insert.js");
|
||||
var update = require(pathThumbnails + "/handlers/dbFunctions/update.js");
|
||||
|
||||
function checkTimeout(
|
||||
function check(
|
||||
type,
|
||||
timeout,
|
||||
channel,
|
||||
@@ -15,13 +16,12 @@ function checkTimeout(
|
||||
socket,
|
||||
error_message
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (conf_pass != "" && conf_pass == this_pass) {
|
||||
resolve();
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
var docs = await find("timeout_api",
|
||||
{
|
||||
var docs = await find("timeout_api", {
|
||||
type: type,
|
||||
guid: guid
|
||||
});
|
||||
@@ -32,12 +32,12 @@ function checkTimeout(
|
||||
|
||||
var retry_in = (date.getTime() - now.getTime()) / 1000;
|
||||
if (retry_in > 0) {
|
||||
if (typeof error_callback == "function") {
|
||||
reject();
|
||||
if (!error_message) {
|
||||
resolve(false);
|
||||
return;
|
||||
} else if (error_message) {
|
||||
var sOrNot =
|
||||
Math.ceil(retry_in) > 1 || Math.ceil(retry_in) == 0 ? "s" : "";
|
||||
Math.ceil(retry_in) > 1 || Math.ceil(retry_in) == 0 ? "s" : "";
|
||||
socket.emit(
|
||||
"toast",
|
||||
error_message + Math.ceil(retry_in) + " second" + sOrNot + "."
|
||||
@@ -49,18 +49,20 @@ function checkTimeout(
|
||||
}
|
||||
}
|
||||
var now_date = new Date();
|
||||
await update("timeout_api",
|
||||
{ type: type, guid: guid },
|
||||
{
|
||||
$set: {
|
||||
createdAt: now_date,
|
||||
type: type,
|
||||
guid: guid
|
||||
}
|
||||
},
|
||||
{ upsert: true });
|
||||
resolve();
|
||||
await update(
|
||||
"timeout_api",
|
||||
{ type: type, guid: guid },
|
||||
{
|
||||
$set: {
|
||||
createdAt: now_date,
|
||||
type: type,
|
||||
guid: guid
|
||||
}
|
||||
},
|
||||
{ upsert: true }
|
||||
);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.checkTimeout = checkTimeout;
|
||||
module.exports.check = check;
|
||||
|
||||
Reference in New Issue
Block a user