]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/fixtures/peertube-plugin-test/main.js
1 async
function register ({ registerHook
, registerSetting
, settingsManager
, storageManager
, peertubeHelpers
}) {
3 'action:application.listening',
5 'action:api.video.updated',
6 'action:api.video.deleted',
7 'action:api.video.uploaded',
8 'action:api.video.viewed',
10 'action:api.video-thread.created',
11 'action:api.video-comment-reply.created',
12 'action:api.video-comment.deleted'
15 for (const h
of actionHooks
) {
18 handler: () => peertubeHelpers
.logger
.debug('Run hook %s.', h
)
23 target: 'filter:api.videos.list.params',
24 handler: obj
=> addToCount(obj
)
28 target: 'filter:api.videos.list.result',
29 handler: obj
=> ({ data: obj
.data
, total: obj
.total
+ 1 })
33 target: 'filter:api.video.get.result',
42 target: 'filter:api.video.upload.accept.result',
43 handler: ({ accepted
}, { videoBody
}) => {
44 if (accepted
!== false) return { accepted: true }
45 if (videoBody
.name
.indexOf('bad word') !== -1) return { accepted: false, errorMessage: 'bad word '}
47 return { accepted: true }
52 async
function unregister () {
61 // ############################################################################
63 function addToCount (obj
) {
64 return Object
.assign({}, obj
, { count: obj
.count
+ 1 })