2020-04-09 11:00:30 +02:00
|
|
|
async function register ({
|
2020-04-09 11:35:29 +02:00
|
|
|
peertubeHelpers,
|
|
|
|
registerHook
|
2020-04-09 11:00:30 +02:00
|
|
|
}) {
|
2020-04-09 11:35:29 +02:00
|
|
|
const logger = peertubeHelpers.logger
|
|
|
|
|
|
|
|
logger.info('Hello world from plugin four')
|
2020-04-09 11:00:30 +02:00
|
|
|
|
|
|
|
const username = 'root'
|
|
|
|
const results = await peertubeHelpers.database.query(
|
|
|
|
'SELECT "email" from "user" WHERE "username" = $username',
|
|
|
|
{
|
|
|
|
type: 'SELECT',
|
|
|
|
bind: { username }
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2020-04-09 11:35:29 +02:00
|
|
|
logger.info('root email is ' + results[0]['email'])
|
|
|
|
|
|
|
|
registerHook({
|
|
|
|
target: 'action:api.video.viewed',
|
|
|
|
handler: async ({ video }) => {
|
|
|
|
await peertubeHelpers.videos.removeVideo(video.id)
|
|
|
|
|
|
|
|
logger.info('Video deleted by plugin four.')
|
|
|
|
}
|
|
|
|
})
|
2020-04-09 11:00:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function unregister () {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
register,
|
|
|
|
unregister
|
|
|
|
}
|
|
|
|
|
|
|
|
// ###########################################################################
|