From 2760b454a761f6af3138b2fb5f34340772ab0d1e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Oct 2021 14:37:04 +0200 Subject: Deprecate filter video query Introduce include and isLocal instead --- shared/extra-utils/videos/videos-command.ts | 10 +++++----- shared/models/search/videos-common-query.model.ts | 17 +++++++++++------ shared/models/search/videos-search-query.model.ts | 3 +++ shared/models/videos/index.ts | 3 ++- shared/models/videos/video-filter.type.ts | 1 + shared/models/videos/video-include.enum.ts | 7 +++++++ shared/models/videos/video-query.type.ts | 1 - shared/models/videos/video.model.ts | 20 ++++++++++++-------- 8 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 shared/models/videos/video-filter.type.ts create mode 100644 shared/models/videos/video-include.enum.ts delete mode 100644 shared/models/videos/video-query.type.ts (limited to 'shared') diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index c1a9ec806..68241f062 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts @@ -18,8 +18,7 @@ import { VideoDetails, VideoFileMetadata, VideoPrivacy, - VideosCommonQuery, - VideosWithSearchCommonQuery + VideosCommonQuery } from '@shared/models' import { buildAbsoluteFixturePath, wait } from '../miscs' import { unwrapBody } from '../requests' @@ -246,7 +245,7 @@ export class VideosCommand extends AbstractCommand { }) } - listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { + listByAccount (options: OverrideCommandOptions & VideosCommonQuery & { handle: string }) { const { handle, search } = options @@ -262,7 +261,7 @@ export class VideosCommand extends AbstractCommand { }) } - listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { + listByChannel (options: OverrideCommandOptions & VideosCommonQuery & { handle: string }) { const { handle } = options @@ -605,7 +604,8 @@ export class VideosCommand extends AbstractCommand { 'languageOneOf', 'tagsOneOf', 'tagsAllOf', - 'filter', + 'isLocal', + 'include', 'skipCount' ]) } diff --git a/shared/models/search/videos-common-query.model.ts b/shared/models/search/videos-common-query.model.ts index 2f2e9a934..55a98e302 100644 --- a/shared/models/search/videos-common-query.model.ts +++ b/shared/models/search/videos-common-query.model.ts @@ -1,4 +1,4 @@ -import { VideoFilter } from '../videos' +import { VideoInclude } from '../videos/video-include.enum' import { BooleanBothQuery } from './boolean-both-query.model' // These query parameters can be used with any endpoint that list videos @@ -11,6 +11,12 @@ export interface VideosCommonQuery { isLive?: boolean + // FIXME: deprecated in 4.0 in favour of isLocal and include, to remove + filter?: never + + isLocal?: boolean + include?: VideoInclude + categoryOneOf?: number[] licenceOneOf?: number[] @@ -20,17 +26,16 @@ export interface VideosCommonQuery { tagsOneOf?: string[] tagsAllOf?: string[] - filter?: VideoFilter - skipCount?: boolean + + search?: string } export interface VideosCommonQueryAfterSanitize extends VideosCommonQuery { start: number count: number sort: string -} -export interface VideosWithSearchCommonQuery extends VideosCommonQuery { - search?: string + // FIXME: deprecated in 4.0, to remove + filter?: never } diff --git a/shared/models/search/videos-search-query.model.ts b/shared/models/search/videos-search-query.model.ts index a5436879d..447c72806 100644 --- a/shared/models/search/videos-search-query.model.ts +++ b/shared/models/search/videos-search-query.model.ts @@ -23,4 +23,7 @@ export interface VideosSearchQueryAfterSanitize extends VideosSearchQuery { start: number count: number sort: string + + // FIXME: deprecated in 4.0, to remove + filter?: never } diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts index 733c433a0..3d3eedcc6 100644 --- a/shared/models/videos/index.ts +++ b/shared/models/videos/index.ts @@ -19,7 +19,8 @@ export * from './video-file-metadata.model' export * from './video-file.model' export * from './video-privacy.enum' -export * from './video-query.type' +export * from './video-filter.type' +export * from './video-include.enum' export * from './video-rate.type' export * from './video-resolution.enum' diff --git a/shared/models/videos/video-filter.type.ts b/shared/models/videos/video-filter.type.ts new file mode 100644 index 000000000..e641a401c --- /dev/null +++ b/shared/models/videos/video-filter.type.ts @@ -0,0 +1 @@ +export type VideoFilter = 'local' | 'all-local' | 'all' diff --git a/shared/models/videos/video-include.enum.ts b/shared/models/videos/video-include.enum.ts new file mode 100644 index 000000000..fa720b348 --- /dev/null +++ b/shared/models/videos/video-include.enum.ts @@ -0,0 +1,7 @@ +export const enum VideoInclude { + NONE = 0, + NOT_PUBLISHED_STATE = 1 << 0, + HIDDEN_PRIVACY = 1 << 1, + BLACKLISTED = 1 << 2, + BLOCKED_OWNER = 1 << 3 +} diff --git a/shared/models/videos/video-query.type.ts b/shared/models/videos/video-query.type.ts deleted file mode 100644 index e641a401c..000000000 --- a/shared/models/videos/video-query.type.ts +++ /dev/null @@ -1 +0,0 @@ -export type VideoFilter = 'local' | 'all-local' | 'all' diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 4a7e399a2..dadde38af 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts @@ -43,13 +43,6 @@ export interface Video { dislikes: number nsfw: boolean - waitTranscoding?: boolean - state?: VideoConstant - scheduledUpdate?: VideoScheduleUpdate - - blacklisted?: boolean - blacklistedReason?: string - account: AccountSummary channel: VideoChannelSummary @@ -58,6 +51,17 @@ export interface Video { } pluginData?: any + + // Additional attributes dependending on the query + waitTranscoding?: boolean + state?: VideoConstant + scheduledUpdate?: VideoScheduleUpdate + + blacklisted?: boolean + blacklistedReason?: string + + blockedOwner?: boolean + blockedServer?: boolean } export interface VideoDetails extends Video { @@ -70,7 +74,7 @@ export interface VideoDetails extends Video { commentsEnabled: boolean downloadEnabled: boolean - // Not optional in details (unlike in Video) + // Not optional in details (unlike in parent Video) waitTranscoding: boolean state: VideoConstant -- cgit v1.2.3