From 2158ac90341dc3fcae958540de65032da25c8d6e Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 14 May 2020 11:10:26 +0200 Subject: Add server plugin filter hooks for import with torrent and url (#2621) * Add server plugin filter hooks for import with torrent and url * WIP: pre and post-import filter hooks * Rebased * Cleanup filters to accept imports Co-authored-by: Chocobozzz --- shared/models/plugins/server-hook.model.ts | 6 +++++- shared/models/server/job.model.ts | 7 +++++-- shared/models/videos/import/video-import-state.enum.ts | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'shared/models') diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts index 20f89b86d..5f812904f 100644 --- a/shared/models/plugins/server-hook.model.ts +++ b/shared/models/plugins/server-hook.model.ts @@ -9,9 +9,13 @@ export const serverFilterHookObject = { // Used to get detailed video information (video watch page for example) 'filter:api.video.get.result': true, - // Filter the result of the accept upload function + // Filter the result of the accept upload, import via torrent or url functions // If this function returns false then the upload is aborted with an error 'filter:api.video.upload.accept.result': true, + 'filter:api.video.pre-import-url.accept.result': true, + 'filter:api.video.pre-import-torrent.accept.result': true, + 'filter:api.video.post-import-url.accept.result': true, + 'filter:api.video.post-import-torrent.accept.result': true, // Filter the result of the accept comment (thread or reply) functions // If the functions return false then the user cannot post its comment 'filter:api.video-thread.create.accept.result': true, diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index 57d61c480..61010e5a8 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts @@ -70,8 +70,11 @@ export type VideoFileImportPayload = { filePath: string } +export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file' +export type VideoImportYoutubeDLPayloadType = 'youtube-dl' + export type VideoImportYoutubeDLPayload = { - type: 'youtube-dl' + type: VideoImportYoutubeDLPayloadType videoImportId: number generateThumbnail: boolean @@ -80,7 +83,7 @@ export type VideoImportYoutubeDLPayload = { fileExt?: string } export type VideoImportTorrentPayload = { - type: 'magnet-uri' | 'torrent-file' + type: VideoImportTorrentPayloadType videoImportId: number } export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload diff --git a/shared/models/videos/import/video-import-state.enum.ts b/shared/models/videos/import/video-import-state.enum.ts index b178fbf3a..8421b8ca7 100644 --- a/shared/models/videos/import/video-import-state.enum.ts +++ b/shared/models/videos/import/video-import-state.enum.ts @@ -1,5 +1,6 @@ export enum VideoImportState { PENDING = 1, SUCCESS = 2, - FAILED = 3 + FAILED = 3, + REJECTED = 4 } -- cgit v1.2.3