return promise
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ale 2024-11-10 11:09:13 +01:00
parent 938d5f804c
commit 136b7e40d6

View File

@ -33,9 +33,9 @@ module.exports = async (client, apex, app) => {
redirect: 'follow' redirect: 'follow'
}) })
setImmediate(() => clearTimeout(timeout)) setImmediate(() => clearTimeout(timeout))
return await response.json() return response.json()
} catch (e) { } catch (e) {
setImmediate(() => { return setImmediate(() => {
clearTimeout(timeout) clearTimeout(timeout)
ac.abort() ac.abort()
}) })
@ -79,7 +79,7 @@ module.exports = async (client, apex, app) => {
} }
}) })
app.locals.created++ 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 { } else {
const elasticinstance = instancelocated[0]._source.blocks || [] const elasticinstance = instancelocated[0]._source.blocks || []
if (Array.isArray(elasticinstance)) { 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) { 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)) 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) { 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 + '.') console.log('Done: ' + server + ' - ' + i + ' parts with exit ' + exit + '.')
} }
})) }))
await scanReturn() return scanReturn()
} else { } else {
await scanReturn() return scanReturn()
} }
} catch (e) { } catch (e) {
// console.error(e) // console.error(e)
await scanReturn() return scanReturn()
} }
} else { } else {
await scanReturn() return scanReturn()
} }
}, },
job = schedule.scheduleJob('0 ' + constant.schedule + ' * * *', async () => { 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) 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()
} }