From 136b7e40d6c559dbcd372245c4e7028e136a6e85 Mon Sep 17 00:00:00 2001 From: ale Date: Sun, 10 Nov 2024 11:09:13 +0100 Subject: [PATCH] return promise --- lib/fediblock.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/fediblock.js b/lib/fediblock.js index e932dbd..53ac863 100644 --- a/lib/fediblock.js +++ b/lib/fediblock.js @@ -33,9 +33,9 @@ module.exports = async (client, apex, app) => { redirect: 'follow' }) setImmediate(() => clearTimeout(timeout)) - return await response.json() + return response.json() } catch (e) { - setImmediate(() => { + return setImmediate(() => { clearTimeout(timeout) ac.abort() }) @@ -79,7 +79,7 @@ module.exports = async (client, apex, app) => { } }) app.locals.created++ - return await util.sendFederatedMessage(constant.nick, 'New Fediblock Instance', `Fediblock Instance ${instance} with ${json.length} blocks - https://${constant.apexdomain}#${instance}`, getAccount(api)) + return util.sendFederatedMessage(constant.nick, 'New Fediblock Instance', `Fediblock Instance ${instance} with ${json.length} blocks - https://${constant.apexdomain}#${instance}`, getAccount(api)) } else { const elasticinstance = instancelocated[0]._source.blocks || [] if (Array.isArray(elasticinstance)) { @@ -104,7 +104,7 @@ module.exports = async (client, apex, app) => { if (instancelocated[0]._source.api && instancelocated[0]._source.api.uri && instancelocated[0]._source.api.contact_account && instancelocated[0]._source.api.contact_account.acct) { const difference = blocks.filter(block => block.domain && block.domain.trim().length > 0 && !elasticinstance.some(instance => block.domain === instance.domain)) if (difference.length > 0 && difference.length < 50) { - return await util.sendFederatedMessage(constant.nick, 'Detected #Fediblock by Fediblock Instance', `You blocked new instances: ${difference.map(d => d.domain).join(', ')} - https://${constant.apexdomain}#${instance}`, getAccount(instancelocated[0]._source.api)) + return util.sendFederatedMessage(constant.nick, 'Detected #Fediblock by Fediblock Instance', `You blocked new instances: ${difference.map(d => d.domain).join(', ')} - https://${constant.apexdomain}#${instance}`, getAccount(instancelocated[0]._source.api)) } } } @@ -223,20 +223,20 @@ module.exports = async (client, apex, app) => { console.log('Done: ' + server + ' - ' + i + ' parts with exit ' + exit + '.') } })) - await scanReturn() + return scanReturn() } else { - await scanReturn() + return scanReturn() } } catch (e) { // console.error(e) - await scanReturn() + return scanReturn() } } else { - await scanReturn() + return scanReturn() } }, job = schedule.scheduleJob('0 ' + constant.schedule + ' * * *', async () => { await util.sendFederatedMessage(constant.nick, null, 'Scanning ' + app.locals.server + ' instance with ' + app.locals.scantotal + ' peers\nScanned ' + app.locals.peers + ' peers from ' + app.locals.instances + ' instances, ' + app.locals.created + ' created, ' + app.locals.updated + ' updated\nhttps://' + constant.apexdomain) }) - return await scanReturn() + return scanReturn() }