From 4bc45da342597fb49593fc14c40f8dc5a97bb64e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Mar 2021 11:54:08 +0100 Subject: Add hooks support for video download --- server/tests/fixtures/peertube-plugin-test/main.js | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'server/tests/fixtures') diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index 305d92002..9913d0846 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js @@ -184,6 +184,32 @@ async function register ({ registerHook, registerSetting, settingsManager, stora return result } }) + + registerHook({ + target: 'filter:api.download.torrent.allowed.result', + handler: (result, params) => { + if (params && params.downloadName.includes('bad torrent')) { + return { allowed: false, errorMessage: 'Liu Bei' } + } + + return result + } + }) + + registerHook({ + target: 'filter:api.download.video.allowed.result', + handler: (result, params) => { + if (params && !params.streamingPlaylist && params.video.name.includes('bad file')) { + return { allowed: false, errorMessage: 'Cao Cao' } + } + + if (params && params.streamingPlaylist && params.video.name.includes('bad playlist file')) { + return { allowed: false, errorMessage: 'Sun Jian' } + } + + return result + } + }) } async function unregister () { -- cgit v1.2.3