2019-07-26 12:45:53 +00:00
|
|
|
async function register ({
|
|
|
|
registerHook,
|
|
|
|
registerSetting,
|
|
|
|
settingsManager,
|
|
|
|
storageManager,
|
|
|
|
videoCategoryManager,
|
|
|
|
videoLicenceManager,
|
|
|
|
videoLanguageManager
|
|
|
|
}) {
|
2019-07-16 09:53:38 +00:00
|
|
|
const defaultAdmin = 'PeerTube admin'
|
|
|
|
|
|
|
|
registerHook({
|
|
|
|
target: 'action:application.listening',
|
|
|
|
handler: () => displayHelloWorld(settingsManager, defaultAdmin)
|
|
|
|
})
|
|
|
|
|
2019-07-22 14:40:52 +00:00
|
|
|
registerHook({
|
|
|
|
target: 'unknown-hook',
|
|
|
|
handler: () => console.log('fake hook')
|
|
|
|
})
|
|
|
|
|
2019-07-16 09:53:38 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'admin-name',
|
|
|
|
label: 'Admin name',
|
|
|
|
type: 'input',
|
2019-07-26 07:42:52 +00:00
|
|
|
private: true,
|
2019-07-16 09:53:38 +00:00
|
|
|
default: defaultAdmin
|
|
|
|
})
|
|
|
|
|
2019-07-26 07:42:52 +00:00
|
|
|
registerSetting({
|
|
|
|
name: 'user-name',
|
|
|
|
label: 'User name',
|
|
|
|
type: 'input',
|
|
|
|
private: false
|
|
|
|
})
|
|
|
|
|
2019-07-16 09:53:38 +00:00
|
|
|
const value = await storageManager.getData('toto')
|
|
|
|
console.log(value)
|
|
|
|
|
|
|
|
await storageManager.storeData('toto', 'hello' + new Date())
|
2019-07-26 12:45:53 +00:00
|
|
|
|
|
|
|
videoLanguageManager.addLanguage('al_bhed', 'Al Bhed')
|
|
|
|
videoLanguageManager.deleteLanguage('fr')
|
|
|
|
|
|
|
|
videoCategoryManager.addCategory(42, 'Best category')
|
|
|
|
videoCategoryManager.deleteCategory(1) // Music
|
|
|
|
|
|
|
|
videoLicenceManager.addLicence(42, 'Best licence')
|
|
|
|
videoLicenceManager.deleteLicence(7) // Public domain
|
2019-07-16 09:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function unregister () {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
register,
|
|
|
|
unregister
|
|
|
|
}
|
|
|
|
|
|
|
|
// ############################################################################
|
|
|
|
|
|
|
|
async function displayHelloWorld (settingsManager, defaultAdmin) {
|
|
|
|
let value = await settingsManager.getSetting('admin-name')
|
|
|
|
if (!value) value = defaultAdmin
|
|
|
|
|
|
|
|
console.log('hello world ' + value)
|
|
|
|
}
|