This commit is contained in:
parent
6c56252145
commit
5deb70a0b0
@ -238,5 +238,5 @@ module.exports = async (client, apex, app) => {
|
|||||||
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)
|
||||||
})
|
})
|
||||||
await scanReturn()
|
return await scanReturn()
|
||||||
}
|
}
|
||||||
|
86
server.js
86
server.js
@ -54,7 +54,48 @@ const apexinstance = require('./lib/apex'),
|
|||||||
},
|
},
|
||||||
itemsPerPage: 200
|
itemsPerPage: 200
|
||||||
}),
|
}),
|
||||||
server = http.createServer(app).listen(4000, () => {
|
register = async () => {
|
||||||
|
const admin = await apex.store.getObject(apex.utils.usernameToIRI('admin'), true)
|
||||||
|
if (!admin) {
|
||||||
|
const adminaccount = await apex.createActor('admin', 'Fediblock Admin', 'Fediblock Admin - https://' + constant.apexdomain,
|
||||||
|
{ type: 'Image', mediaType: 'image/png', url: constant.icon }, 'Service'),
|
||||||
|
keys = generateKeyPairSync('rsa', {
|
||||||
|
modulusLength: 2048,
|
||||||
|
publicKeyEncoding: {
|
||||||
|
type: 'spki',
|
||||||
|
format: 'pem'
|
||||||
|
},
|
||||||
|
privateKeyEncoding: {
|
||||||
|
type: 'pkcs8',
|
||||||
|
format: 'pem'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
adminaccount.publicKey[0].publicKeyPem[0] = keys.publicKey
|
||||||
|
adminaccount._meta.privateKey = keys.privateKey
|
||||||
|
await apex.store.saveObject(adminaccount)
|
||||||
|
const bot = await apex.createActor(constant.nick, 'Fediblock Bot', 'Fediblock #Bot - https://' + constant.apexdomain,
|
||||||
|
{ type: 'Image', mediaType: 'image/png', url: constant.icon }, 'Person'),
|
||||||
|
keysbot = generateKeyPairSync('rsa', {
|
||||||
|
modulusLength: 2048,
|
||||||
|
publicKeyEncoding: {
|
||||||
|
type: 'spki',
|
||||||
|
format: 'pem'
|
||||||
|
},
|
||||||
|
privateKeyEncoding: {
|
||||||
|
type: 'pkcs8',
|
||||||
|
format: 'pem'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
bot.publicKey[0].publicKeyPem[0] = keysbot.publicKey
|
||||||
|
bot._meta.privateKey = keysbot.privateKey
|
||||||
|
await apex.store.saveObject(bot)
|
||||||
|
apex.systemUser = adminaccount
|
||||||
|
apex.store.setup(adminaccount)
|
||||||
|
} else {
|
||||||
|
apex.systemUser = admin
|
||||||
|
}
|
||||||
|
},
|
||||||
|
connect = () => {
|
||||||
mongoclient.connect()
|
mongoclient.connect()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const exists = await client.indices.exists({ index: constant.index })
|
const exists = await client.indices.exists({ index: constant.index })
|
||||||
@ -69,45 +110,7 @@ const apexinstance = require('./lib/apex'),
|
|||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
try {
|
try {
|
||||||
const admin = await apex.store.getObject(apex.utils.usernameToIRI('admin'), true)
|
await register()
|
||||||
if (!admin) {
|
|
||||||
const adminaccount = await apex.createActor('admin', 'Fediblock Admin', 'Fediblock Admin - https://' + constant.apexdomain,
|
|
||||||
{ type: 'Image', mediaType: 'image/png', url: constant.icon }, 'Service'),
|
|
||||||
keys = generateKeyPairSync('rsa', {
|
|
||||||
modulusLength: 2048,
|
|
||||||
publicKeyEncoding: {
|
|
||||||
type: 'spki',
|
|
||||||
format: 'pem'
|
|
||||||
},
|
|
||||||
privateKeyEncoding: {
|
|
||||||
type: 'pkcs8',
|
|
||||||
format: 'pem'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
adminaccount.publicKey[0].publicKeyPem[0] = keys.publicKey
|
|
||||||
adminaccount._meta.privateKey = keys.privateKey
|
|
||||||
await apex.store.saveObject(adminaccount)
|
|
||||||
const bot = await apex.createActor(constant.nick, 'Fediblock Bot', 'Fediblock #Bot - https://' + constant.apexdomain,
|
|
||||||
{ type: 'Image', mediaType: 'image/png', url: constant.icon }, 'Person'),
|
|
||||||
keysbot = generateKeyPairSync('rsa', {
|
|
||||||
modulusLength: 2048,
|
|
||||||
publicKeyEncoding: {
|
|
||||||
type: 'spki',
|
|
||||||
format: 'pem'
|
|
||||||
},
|
|
||||||
privateKeyEncoding: {
|
|
||||||
type: 'pkcs8',
|
|
||||||
format: 'pem'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
bot.publicKey[0].publicKeyPem[0] = keysbot.publicKey
|
|
||||||
bot._meta.privateKey = keysbot.privateKey
|
|
||||||
await apex.store.saveObject(bot)
|
|
||||||
apex.systemUser = adminaccount
|
|
||||||
apex.store.setup(adminaccount)
|
|
||||||
} else {
|
|
||||||
apex.systemUser = admin
|
|
||||||
}
|
|
||||||
taskdeletedup(client)
|
taskdeletedup(client)
|
||||||
await apex.startDelivery()
|
await apex.startDelivery()
|
||||||
console.log('Server listening on ' + server.address().address + ':' + server.address().port)
|
console.log('Server listening on ' + server.address().address + ':' + server.address().port)
|
||||||
@ -116,6 +119,9 @@ const apexinstance = require('./lib/apex'),
|
|||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
server = http.createServer(app).listen(4000, () => {
|
||||||
|
connect()
|
||||||
})
|
})
|
||||||
|
|
||||||
app.locals.scan = new events.EventEmitter()
|
app.locals.scan = new events.EventEmitter()
|
||||||
|
Loading…
Reference in New Issue
Block a user