change secret-stack plugin structure

This commit is contained in:
Andre Staltz 2024-01-02 12:32:25 +02:00
parent 6b96852808
commit 41e1f9502f
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 239 additions and 242 deletions

View File

@ -50,27 +50,11 @@ function assertValidConfig(config) {
}
}
module.exports = {
name: 'promise',
manifest: {
// management
create: 'async',
revoke: 'async',
// promises
follow: 'async',
accountAdd: 'async',
},
permissions: {
anonymous: {
allow: ['follow', 'accountAdd'],
},
},
/**
* @param {{ db: PPPPPDB | null; set: PPPPPSet | null }} peer
* @param {Config} config
*/
init(peer, config) {
function initPromise(peer, config) {
assertDBPlugin(peer)
assertValidConfig(config)
const devicePromisesFile = Path.join(config.global.path, 'promises.json')
@ -85,7 +69,6 @@ module.exports = {
if (err) {
if (err.code === 'ENOENT') {
save((err, _) => {
// prettier-ignore
if (err) return console.log('Problem creating promises file:', err)
else loaded = true
})
@ -121,7 +104,6 @@ module.exports = {
break
}
default:
// prettier-ignore
return Error('Invalid promise type: ' + JSON.stringify(promise))
}
return null
@ -313,5 +295,20 @@ module.exports = {
}
return { create, revoke, follow, accountAdd }
}
exports.name = 'promise'
exports.manifest = {
// management
create: 'async',
revoke: 'async',
// promises
follow: 'async',
accountAdd: 'async',
}
exports.init = initPromise
exports.permissions = {
anonymous: {
allow: ['follow', 'accountAdd'],
},
}