aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-17 16:02:38 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-06-25 14:44:01 +0200
commit37a44fc915eef2140e22ceb96aba6b6eb2509007 (patch)
treedd4a370ecc96cf38c99b940261aadc27065da7ae /shared
parent33eb19e5199cc9fa4d73c6675c97508e3e072ef9 (diff)
downloadPeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.gz
PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.zst
PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.zip
Add ability to search playlists
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/index.ts2
-rw-r--r--shared/extra-utils/search/video-playlists.ts36
-rw-r--r--shared/models/plugins/client/client-hook.model.ts5
-rw-r--r--shared/models/plugins/server/server-hook.model.ts4
-rw-r--r--shared/models/search/index.ts3
-rw-r--r--shared/models/search/video-channels-search-query.model.ts2
-rw-r--r--shared/models/search/video-playlists-search-query.model.ts9
-rw-r--r--shared/models/server/job.model.ts1
-rw-r--r--shared/models/server/peertube-problem-document.model.ts2
-rw-r--r--shared/models/videos/playlist/video-playlist.model.ts4
10 files changed, 63 insertions, 5 deletions
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index 3bc09ead5..87ee8abba 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -19,6 +19,8 @@ export * from './plugins/mock-blocklist'
19export * from './requests/check-api-params' 19export * from './requests/check-api-params'
20export * from './requests/requests' 20export * from './requests/requests'
21 21
22export * from './search/video-channels'
23export * from './search/video-playlists'
22export * from './search/videos' 24export * from './search/videos'
23 25
24export * from './server/activitypub' 26export * from './server/activitypub'
diff --git a/shared/extra-utils/search/video-playlists.ts b/shared/extra-utils/search/video-playlists.ts
new file mode 100644
index 000000000..c22831df7
--- /dev/null
+++ b/shared/extra-utils/search/video-playlists.ts
@@ -0,0 +1,36 @@
1import { VideoPlaylistsSearchQuery } from '@shared/models'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { makeGetRequest } from '../requests/requests'
4
5function searchVideoPlaylists (url: string, search: string, token?: string, statusCodeExpected = HttpStatusCode.OK_200) {
6 const path = '/api/v1/search/video-playlists'
7
8 return makeGetRequest({
9 url,
10 path,
11 query: {
12 sort: '-createdAt',
13 search
14 },
15 token,
16 statusCodeExpected
17 })
18}
19
20function advancedVideoPlaylistSearch (url: string, search: VideoPlaylistsSearchQuery) {
21 const path = '/api/v1/search/video-playlists'
22
23 return makeGetRequest({
24 url,
25 path,
26 query: search,
27 statusCodeExpected: HttpStatusCode.OK_200
28 })
29}
30
31// ---------------------------------------------------------------------------
32
33export {
34 searchVideoPlaylists,
35 advancedVideoPlaylistSearch
36}
diff --git a/shared/models/plugins/client/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts
index 546866845..cedd1be61 100644
--- a/shared/models/plugins/client/client-hook.model.ts
+++ b/shared/models/plugins/client/client-hook.model.ts
@@ -37,9 +37,12 @@ export const clientFilterHookObject = {
37 // Filter params/result of the function that fetch videos according to the user search 37 // Filter params/result of the function that fetch videos according to the user search
38 'filter:api.search.videos.list.params': true, 38 'filter:api.search.videos.list.params': true,
39 'filter:api.search.videos.list.result': true, 39 'filter:api.search.videos.list.result': true,
40 // Filter params/result of the function that fetch video-channels according to the user search 40 // Filter params/result of the function that fetch video channels according to the user search
41 'filter:api.search.video-channels.list.params': true, 41 'filter:api.search.video-channels.list.params': true,
42 'filter:api.search.video-channels.list.result': true, 42 'filter:api.search.video-channels.list.result': true,
43 // Filter params/result of the function that fetch video playlists according to the user search
44 'filter:api.search.video-playlists.list.params': true,
45 'filter:api.search.video-playlists.list.result': true,
43 46
44 // Filter form 47 // Filter form
45 'filter:api.signup.registration.create.params': true, 48 'filter:api.signup.registration.create.params': true,
diff --git a/shared/models/plugins/server/server-hook.model.ts b/shared/models/plugins/server/server-hook.model.ts
index 88277af5a..dae243dbf 100644
--- a/shared/models/plugins/server/server-hook.model.ts
+++ b/shared/models/plugins/server/server-hook.model.ts
@@ -27,6 +27,10 @@ export const serverFilterHookObject = {
27 'filter:api.search.video-channels.local.list.result': true, 27 'filter:api.search.video-channels.local.list.result': true,
28 'filter:api.search.video-channels.index.list.params': true, 28 'filter:api.search.video-channels.index.list.params': true,
29 'filter:api.search.video-channels.index.list.result': true, 29 'filter:api.search.video-channels.index.list.result': true,
30 'filter:api.search.video-playlists.local.list.params': true,
31 'filter:api.search.video-playlists.local.list.result': true,
32 'filter:api.search.video-playlists.index.list.params': true,
33 'filter:api.search.video-playlists.index.list.result': true,
30 34
31 // Filter the result of the get function 35 // Filter the result of the get function
32 // Used to get detailed video information (video watch page for example) 36 // Used to get detailed video information (video watch page for example)
diff --git a/shared/models/search/index.ts b/shared/models/search/index.ts
index 697ceccb1..50aeeddc8 100644
--- a/shared/models/search/index.ts
+++ b/shared/models/search/index.ts
@@ -1,5 +1,6 @@
1export * from './boolean-both-query.model' 1export * from './boolean-both-query.model'
2export * from './search-target-query.model' 2export * from './search-target-query.model'
3export * from './videos-common-query.model' 3export * from './videos-common-query.model'
4export * from './videos-search-query.model'
5export * from './video-channels-search-query.model' 4export * from './video-channels-search-query.model'
5export * from './video-playlists-search-query.model'
6export * from './videos-search-query.model'
diff --git a/shared/models/search/video-channels-search-query.model.ts b/shared/models/search/video-channels-search-query.model.ts
index c96aa8c1d..8f93c4bd5 100644
--- a/shared/models/search/video-channels-search-query.model.ts
+++ b/shared/models/search/video-channels-search-query.model.ts
@@ -1,4 +1,4 @@
1import { SearchTargetQuery } from "./search-target-query.model" 1import { SearchTargetQuery } from './search-target-query.model'
2 2
3export interface VideoChannelsSearchQuery extends SearchTargetQuery { 3export interface VideoChannelsSearchQuery extends SearchTargetQuery {
4 search: string 4 search: string
diff --git a/shared/models/search/video-playlists-search-query.model.ts b/shared/models/search/video-playlists-search-query.model.ts
new file mode 100644
index 000000000..31f05218e
--- /dev/null
+++ b/shared/models/search/video-playlists-search-query.model.ts
@@ -0,0 +1,9 @@
1import { SearchTargetQuery } from './search-target-query.model'
2
3export interface VideoPlaylistsSearchQuery extends SearchTargetQuery {
4 search: string
5
6 start?: number
7 count?: number
8 sort?: string
9}
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts
index e4acfee8d..4ab249e0b 100644
--- a/shared/models/server/job.model.ts
+++ b/shared/models/server/job.model.ts
@@ -53,7 +53,6 @@ export type ActivitypubHttpFetcherPayload = {
53 uri: string 53 uri: string
54 type: FetchType 54 type: FetchType
55 videoId?: number 55 videoId?: number
56 accountId?: number
57} 56}
58 57
59export type ActivitypubHttpUnicastPayload = { 58export type ActivitypubHttpUnicastPayload = {
diff --git a/shared/models/server/peertube-problem-document.model.ts b/shared/models/server/peertube-problem-document.model.ts
index 5e1c320f3..e391d5aad 100644
--- a/shared/models/server/peertube-problem-document.model.ts
+++ b/shared/models/server/peertube-problem-document.model.ts
@@ -1,4 +1,4 @@
1import { HttpStatusCode } from '@shared/core-utils' 1import { HttpStatusCode } from '../../core-utils'
2import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum' 2import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum'
3 3
4export interface PeerTubeProblemDocumentData { 4export interface PeerTubeProblemDocumentData {
diff --git a/shared/models/videos/playlist/video-playlist.model.ts b/shared/models/videos/playlist/video-playlist.model.ts
index f45d0ff88..ab4171ad1 100644
--- a/shared/models/videos/playlist/video-playlist.model.ts
+++ b/shared/models/videos/playlist/video-playlist.model.ts
@@ -8,17 +8,21 @@ export interface VideoPlaylist {
8 uuid: string 8 uuid: string
9 isLocal: boolean 9 isLocal: boolean
10 10
11 url: string
12
11 displayName: string 13 displayName: string
12 description: string 14 description: string
13 privacy: VideoConstant<VideoPlaylistPrivacy> 15 privacy: VideoConstant<VideoPlaylistPrivacy>
14 16
15 thumbnailPath: string 17 thumbnailPath: string
18 thumbnailUrl?: string
16 19
17 videosLength: number 20 videosLength: number
18 21
19 type: VideoConstant<VideoPlaylistType> 22 type: VideoConstant<VideoPlaylistType>
20 23
21 embedPath: string 24 embedPath: string
25 embedUrl?: string
22 26
23 createdAt: Date | string 27 createdAt: Date | string
24 updatedAt: Date | string 28 updatedAt: Date | string