From 22df69fdecf299c8be6acaa25f086249ea9a0085 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 2 Aug 2022 15:29:00 +0200 Subject: Add job queue hooks --- .../fixtures/peertube-plugin-test-four/main.js | 10 +++++++++ server/tests/fixtures/peertube-plugin-test/main.js | 26 +++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'server/tests/fixtures') diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.js index bff42ff40..5194e3e02 100644 --- a/server/tests/fixtures/peertube-plugin-test-four/main.js +++ b/server/tests/fixtures/peertube-plugin-test-four/main.js @@ -88,6 +88,15 @@ async function register ({ return res.json({ routerRoute }) }) + router.get('/user/:id', async (req, res) => { + const user = await peertubeHelpers.user.loadById(req.params.id) + if (!user) return res.status(404).end() + + return res.json({ + username: user.username + }) + }) + router.get('/user', async (req, res) => { const user = await peertubeHelpers.user.getAuthUser(res) if (!user) return res.sendStatus(404) @@ -97,6 +106,7 @@ async function register ({ const isUser = user.role === 2 return res.json({ + id: user.id, username: user.username, displayName: user.Account.name, isAdmin, diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index 2f3809215..f62f6a435 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js @@ -253,6 +253,27 @@ async function register ({ registerHook, registerSetting, settingsManager, stora } }) + registerHook({ + target: 'filter:job-queue.process.params', + handler: (object, context) => { + peertubeHelpers.logger.debug('TOTO.', { object, context }) + + if (context.type !== 'video-studio-edition') return object + + object.data.tasks = [ + { + name: 'cut', + options: { + start: 0, + end: 1 + } + } + ] + + return object + } + }) + // Upload/import/live attributes for (const target of [ 'filter:api.video.upload.video-attribute.result', @@ -284,7 +305,10 @@ async function register ({ registerHook, registerSetting, settingsManager, stora 'filter:api.search.video-playlists.index.list.result', 'filter:api.overviews.videos.list.params', - 'filter:api.overviews.videos.list.result' + 'filter:api.overviews.videos.list.result', + + 'filter:job-queue.process.params', + 'filter:job-queue.process.result' ] for (const h of filterHooks) { -- cgit v1.2.3