diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/accounts.ts | 20 | ||||
-rw-r--r-- | server/controllers/api/search/search-video-channels.ts | 19 | ||||
-rw-r--r-- | server/controllers/api/search/search-video-playlists.ts | 19 | ||||
-rw-r--r-- | server/controllers/api/search/search-videos.ts | 24 | ||||
-rw-r--r-- | server/controllers/api/users/my-subscriptions.ts | 15 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 16 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 16 |
7 files changed, 50 insertions, 79 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index 49a8e3195..55e2aaf62 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { pickCommonVideoQuery } from '@server/helpers/query' | ||
2 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
3 | import { VideosWithSearchCommonQuery } from '@shared/models' | ||
4 | import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 4 | import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
5 | import { getFormattedObjects } from '../../helpers/utils' | 5 | import { getFormattedObjects } from '../../helpers/utils' |
6 | import { JobQueue } from '../../lib/job-queue' | 6 | import { JobQueue } from '../../lib/job-queue' |
@@ -159,27 +159,19 @@ async function listAccountVideos (req: express.Request, res: express.Response) { | |||
159 | const account = res.locals.account | 159 | const account = res.locals.account |
160 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined | 160 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined |
161 | const countVideos = getCountVideos(req) | 161 | const countVideos = getCountVideos(req) |
162 | const query = req.query as VideosWithSearchCommonQuery | 162 | const query = pickCommonVideoQuery(req.query) |
163 | 163 | ||
164 | const apiOptions = await Hooks.wrapObject({ | 164 | const apiOptions = await Hooks.wrapObject({ |
165 | ...query, | ||
166 | |||
165 | followerActorId, | 167 | followerActorId, |
166 | start: query.start, | 168 | search: req.query.search, |
167 | count: query.count, | ||
168 | sort: query.sort, | ||
169 | includeLocalVideos: true, | 169 | includeLocalVideos: true, |
170 | categoryOneOf: query.categoryOneOf, | ||
171 | licenceOneOf: query.licenceOneOf, | ||
172 | languageOneOf: query.languageOneOf, | ||
173 | tagsOneOf: query.tagsOneOf, | ||
174 | tagsAllOf: query.tagsAllOf, | ||
175 | filter: query.filter, | ||
176 | isLive: query.isLive, | ||
177 | nsfw: buildNSFWFilter(res, query.nsfw), | 170 | nsfw: buildNSFWFilter(res, query.nsfw), |
178 | withFiles: false, | 171 | withFiles: false, |
179 | accountId: account.id, | 172 | accountId: account.id, |
180 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, | 173 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, |
181 | countVideos, | 174 | countVideos |
182 | search: query.search | ||
183 | }, 'filter:api.accounts.videos.list.params') | 175 | }, 'filter:api.accounts.videos.list.params') |
184 | 176 | ||
185 | const resultList = await Hooks.wrapPromiseFun( | 177 | const resultList = await Hooks.wrapPromiseFun( |
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts index ae32a6726..eef222506 100644 --- a/server/controllers/api/search/search-video-channels.ts +++ b/server/controllers/api/search/search-video-channels.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { sanitizeUrl } from '@server/helpers/core-utils' | 2 | import { sanitizeUrl } from '@server/helpers/core-utils' |
3 | import { pickSearchChannelQuery } from '@server/helpers/query' | ||
3 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { doJSONRequest } from '@server/helpers/requests' |
4 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
5 | import { WEBSERVER } from '@server/initializers/constants' | 6 | import { WEBSERVER } from '@server/initializers/constants' |
@@ -7,7 +8,7 @@ import { Hooks } from '@server/lib/plugins/hooks' | |||
7 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' | 8 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' |
8 | import { getServerActor } from '@server/models/application/application' | 9 | import { getServerActor } from '@server/models/application/application' |
9 | import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' | 10 | import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' |
10 | import { VideoChannelsSearchQuery } from '../../../../shared/models/search' | 11 | import { VideoChannelsSearchQueryAfterSanitize } from '../../../../shared/models/search' |
11 | import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' | 12 | import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' |
12 | import { logger } from '../../../helpers/logger' | 13 | import { logger } from '../../../helpers/logger' |
13 | import { getFormattedObjects } from '../../../helpers/utils' | 14 | import { getFormattedObjects } from '../../../helpers/utils' |
@@ -45,7 +46,7 @@ export { searchChannelsRouter } | |||
45 | // --------------------------------------------------------------------------- | 46 | // --------------------------------------------------------------------------- |
46 | 47 | ||
47 | function searchVideoChannels (req: express.Request, res: express.Response) { | 48 | function searchVideoChannels (req: express.Request, res: express.Response) { |
48 | const query: VideoChannelsSearchQuery = req.query | 49 | const query = pickSearchChannelQuery(req.query) |
49 | let search = query.search || '' | 50 | let search = query.search || '' |
50 | 51 | ||
51 | const parts = search.split('@') | 52 | const parts = search.split('@') |
@@ -66,7 +67,7 @@ function searchVideoChannels (req: express.Request, res: express.Response) { | |||
66 | return searchVideoChannelsDB(query, res) | 67 | return searchVideoChannelsDB(query, res) |
67 | } | 68 | } |
68 | 69 | ||
69 | async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: express.Response) { | 70 | async function searchVideoChannelsIndex (query: VideoChannelsSearchQueryAfterSanitize, res: express.Response) { |
70 | const result = await buildMutedForSearchIndex(res) | 71 | const result = await buildMutedForSearchIndex(res) |
71 | 72 | ||
72 | const body = await Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-channels.index.list.params') | 73 | const body = await Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-channels.index.list.params') |
@@ -90,17 +91,13 @@ async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: e | |||
90 | } | 91 | } |
91 | } | 92 | } |
92 | 93 | ||
93 | async function searchVideoChannelsDB (query: VideoChannelsSearchQuery, res: express.Response) { | 94 | async function searchVideoChannelsDB (query: VideoChannelsSearchQueryAfterSanitize, res: express.Response) { |
94 | const serverActor = await getServerActor() | 95 | const serverActor = await getServerActor() |
95 | 96 | ||
96 | const apiOptions = await Hooks.wrapObject({ | 97 | const apiOptions = await Hooks.wrapObject({ |
97 | actorId: serverActor.id, | 98 | ...query, |
98 | search: query.search, | 99 | |
99 | start: query.start, | 100 | actorId: serverActor.id |
100 | count: query.count, | ||
101 | sort: query.sort, | ||
102 | host: query.host, | ||
103 | handles: query.handles | ||
104 | }, 'filter:api.search.video-channels.local.list.params') | 101 | }, 'filter:api.search.video-channels.local.list.params') |
105 | 102 | ||
106 | const resultList = await Hooks.wrapPromiseFun( | 103 | const resultList = await Hooks.wrapPromiseFun( |
diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts index bd6a2a564..0a56f19b7 100644 --- a/server/controllers/api/search/search-video-playlists.ts +++ b/server/controllers/api/search/search-video-playlists.ts | |||
@@ -2,6 +2,7 @@ import * as express from 'express' | |||
2 | import { sanitizeUrl } from '@server/helpers/core-utils' | 2 | import { sanitizeUrl } from '@server/helpers/core-utils' |
3 | import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils' | 3 | import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { logger } from '@server/helpers/logger' |
5 | import { pickSearchPlaylistQuery } from '@server/helpers/query' | ||
5 | import { doJSONRequest } from '@server/helpers/requests' | 6 | import { doJSONRequest } from '@server/helpers/requests' |
6 | import { getFormattedObjects } from '@server/helpers/utils' | 7 | import { getFormattedObjects } from '@server/helpers/utils' |
7 | import { CONFIG } from '@server/initializers/config' | 8 | import { CONFIG } from '@server/initializers/config' |
@@ -12,7 +13,7 @@ import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@ser | |||
12 | import { getServerActor } from '@server/models/application/application' | 13 | import { getServerActor } from '@server/models/application/application' |
13 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 14 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
14 | import { MVideoPlaylistFullSummary } from '@server/types/models' | 15 | import { MVideoPlaylistFullSummary } from '@server/types/models' |
15 | import { HttpStatusCode, ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' | 16 | import { HttpStatusCode, ResultList, VideoPlaylist, VideoPlaylistsSearchQueryAfterSanitize } from '@shared/models' |
16 | import { | 17 | import { |
17 | asyncMiddleware, | 18 | asyncMiddleware, |
18 | openapiOperationDoc, | 19 | openapiOperationDoc, |
@@ -44,7 +45,7 @@ export { searchPlaylistsRouter } | |||
44 | // --------------------------------------------------------------------------- | 45 | // --------------------------------------------------------------------------- |
45 | 46 | ||
46 | function searchVideoPlaylists (req: express.Request, res: express.Response) { | 47 | function searchVideoPlaylists (req: express.Request, res: express.Response) { |
47 | const query: VideoPlaylistsSearchQuery = req.query | 48 | const query = pickSearchPlaylistQuery(req.query) |
48 | const search = query.search | 49 | const search = query.search |
49 | 50 | ||
50 | if (isURISearch(search)) return searchVideoPlaylistsURI(search, res) | 51 | if (isURISearch(search)) return searchVideoPlaylistsURI(search, res) |
@@ -56,7 +57,7 @@ function searchVideoPlaylists (req: express.Request, res: express.Response) { | |||
56 | return searchVideoPlaylistsDB(query, res) | 57 | return searchVideoPlaylistsDB(query, res) |
57 | } | 58 | } |
58 | 59 | ||
59 | async function searchVideoPlaylistsIndex (query: VideoPlaylistsSearchQuery, res: express.Response) { | 60 | async function searchVideoPlaylistsIndex (query: VideoPlaylistsSearchQueryAfterSanitize, res: express.Response) { |
60 | const result = await buildMutedForSearchIndex(res) | 61 | const result = await buildMutedForSearchIndex(res) |
61 | 62 | ||
62 | const body = await Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-playlists.index.list.params') | 63 | const body = await Hooks.wrapObject(Object.assign(query, result), 'filter:api.search.video-playlists.index.list.params') |
@@ -80,17 +81,13 @@ async function searchVideoPlaylistsIndex (query: VideoPlaylistsSearchQuery, res: | |||
80 | } | 81 | } |
81 | } | 82 | } |
82 | 83 | ||
83 | async function searchVideoPlaylistsDB (query: VideoPlaylistsSearchQuery, res: express.Response) { | 84 | async function searchVideoPlaylistsDB (query: VideoPlaylistsSearchQueryAfterSanitize, res: express.Response) { |
84 | const serverActor = await getServerActor() | 85 | const serverActor = await getServerActor() |
85 | 86 | ||
86 | const apiOptions = await Hooks.wrapObject({ | 87 | const apiOptions = await Hooks.wrapObject({ |
87 | followerActorId: serverActor.id, | 88 | ...query, |
88 | search: query.search, | 89 | |
89 | start: query.start, | 90 | followerActorId: serverActor.id |
90 | count: query.count, | ||
91 | sort: query.sort, | ||
92 | host: query.host, | ||
93 | uuids: query.uuids | ||
94 | }, 'filter:api.search.video-playlists.local.list.params') | 91 | }, 'filter:api.search.video-playlists.local.list.params') |
95 | 92 | ||
96 | const resultList = await Hooks.wrapPromiseFun( | 93 | const resultList = await Hooks.wrapPromiseFun( |
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts index a4153f3f8..4a6ce0de4 100644 --- a/server/controllers/api/search/search-videos.ts +++ b/server/controllers/api/search/search-videos.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { sanitizeUrl } from '@server/helpers/core-utils' | 2 | import { sanitizeUrl } from '@server/helpers/core-utils' |
3 | import { pickSearchVideoQuery } from '@server/helpers/query' | ||
3 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { doJSONRequest } from '@server/helpers/requests' |
4 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
5 | import { WEBSERVER } from '@server/initializers/constants' | 6 | import { WEBSERVER } from '@server/initializers/constants' |
@@ -7,7 +8,7 @@ import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' | |||
7 | import { Hooks } from '@server/lib/plugins/hooks' | 8 | import { Hooks } from '@server/lib/plugins/hooks' |
8 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' | 9 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' |
9 | import { HttpStatusCode, ResultList, Video } from '@shared/models' | 10 | import { HttpStatusCode, ResultList, Video } from '@shared/models' |
10 | import { VideosSearchQuery } from '../../../../shared/models/search' | 11 | import { VideosSearchQueryAfterSanitize } from '../../../../shared/models/search' |
11 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' | 12 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' |
12 | import { logger } from '../../../helpers/logger' | 13 | import { logger } from '../../../helpers/logger' |
13 | import { getFormattedObjects } from '../../../helpers/utils' | 14 | import { getFormattedObjects } from '../../../helpers/utils' |
@@ -46,7 +47,7 @@ export { searchVideosRouter } | |||
46 | // --------------------------------------------------------------------------- | 47 | // --------------------------------------------------------------------------- |
47 | 48 | ||
48 | function searchVideos (req: express.Request, res: express.Response) { | 49 | function searchVideos (req: express.Request, res: express.Response) { |
49 | const query: VideosSearchQuery = req.query | 50 | const query = pickSearchVideoQuery(req.query) |
50 | const search = query.search | 51 | const search = query.search |
51 | 52 | ||
52 | if (isURISearch(search)) { | 53 | if (isURISearch(search)) { |
@@ -60,10 +61,10 @@ function searchVideos (req: express.Request, res: express.Response) { | |||
60 | return searchVideosDB(query, res) | 61 | return searchVideosDB(query, res) |
61 | } | 62 | } |
62 | 63 | ||
63 | async function searchVideosIndex (query: VideosSearchQuery, res: express.Response) { | 64 | async function searchVideosIndex (query: VideosSearchQueryAfterSanitize, res: express.Response) { |
64 | const result = await buildMutedForSearchIndex(res) | 65 | const result = await buildMutedForSearchIndex(res) |
65 | 66 | ||
66 | let body: VideosSearchQuery = Object.assign(query, result) | 67 | let body = { ...query, ...result } |
67 | 68 | ||
68 | // Use the default instance NSFW policy if not specified | 69 | // Use the default instance NSFW policy if not specified |
69 | if (!body.nsfw) { | 70 | if (!body.nsfw) { |
@@ -97,13 +98,18 @@ async function searchVideosIndex (query: VideosSearchQuery, res: express.Respons | |||
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
100 | async function searchVideosDB (query: VideosSearchQuery, res: express.Response) { | 101 | async function searchVideosDB (query: VideosSearchQueryAfterSanitize, res: express.Response) { |
101 | const apiOptions = await Hooks.wrapObject(Object.assign(query, { | 102 | const apiOptions = await Hooks.wrapObject({ |
103 | ...query, | ||
104 | |||
102 | includeLocalVideos: true, | 105 | includeLocalVideos: true, |
103 | nsfw: buildNSFWFilter(res, query.nsfw), | ||
104 | filter: query.filter, | 106 | filter: query.filter, |
105 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined | 107 | |
106 | }), 'filter:api.search.videos.local.list.params') | 108 | nsfw: buildNSFWFilter(res, query.nsfw), |
109 | user: res.locals.oauth | ||
110 | ? res.locals.oauth.token.User | ||
111 | : undefined | ||
112 | }, 'filter:api.search.videos.local.list.params') | ||
107 | 113 | ||
108 | const resultList = await Hooks.wrapPromiseFun( | 114 | const resultList = await Hooks.wrapPromiseFun( |
109 | VideoModel.searchAndPopulateAccountAndServer, | 115 | VideoModel.searchAndPopulateAccountAndServer, |
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 84f519926..26a715704 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { pickCommonVideoQuery } from '@server/helpers/query' | ||
3 | import { sendUndoFollow } from '@server/lib/activitypub/send' | 4 | import { sendUndoFollow } from '@server/lib/activitypub/send' |
4 | import { VideoChannelModel } from '@server/models/video/video-channel' | 5 | import { VideoChannelModel } from '@server/models/video/video-channel' |
5 | import { VideosCommonQuery } from '@shared/models' | ||
6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' | 7 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' |
8 | import { getFormattedObjects } from '../../../helpers/utils' | 8 | import { getFormattedObjects } from '../../../helpers/utils' |
@@ -170,20 +170,13 @@ async function getUserSubscriptions (req: express.Request, res: express.Response | |||
170 | async function getUserSubscriptionVideos (req: express.Request, res: express.Response) { | 170 | async function getUserSubscriptionVideos (req: express.Request, res: express.Response) { |
171 | const user = res.locals.oauth.token.User | 171 | const user = res.locals.oauth.token.User |
172 | const countVideos = getCountVideos(req) | 172 | const countVideos = getCountVideos(req) |
173 | const query = req.query as VideosCommonQuery | 173 | const query = pickCommonVideoQuery(req.query) |
174 | 174 | ||
175 | const resultList = await VideoModel.listForApi({ | 175 | const resultList = await VideoModel.listForApi({ |
176 | start: query.start, | 176 | ...query, |
177 | count: query.count, | 177 | |
178 | sort: query.sort, | ||
179 | includeLocalVideos: false, | 178 | includeLocalVideos: false, |
180 | categoryOneOf: query.categoryOneOf, | ||
181 | licenceOneOf: query.licenceOneOf, | ||
182 | languageOneOf: query.languageOneOf, | ||
183 | tagsOneOf: query.tagsOneOf, | ||
184 | tagsAllOf: query.tagsAllOf, | ||
185 | nsfw: buildNSFWFilter(res, query.nsfw), | 179 | nsfw: buildNSFWFilter(res, query.nsfw), |
186 | filter: query.filter, | ||
187 | withFiles: false, | 180 | withFiles: false, |
188 | followerActorId: user.Account.Actor.id, | 181 | followerActorId: user.Account.Actor.id, |
189 | user, | 182 | user, |
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 784f97b1e..7bdb33737 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { pickCommonVideoQuery } from '@server/helpers/query' | ||
2 | import { Hooks } from '@server/lib/plugins/hooks' | 3 | import { Hooks } from '@server/lib/plugins/hooks' |
3 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
4 | import { MChannelBannerAccountDefault } from '@server/types/models' | 5 | import { MChannelBannerAccountDefault } from '@server/types/models' |
5 | import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared' | 6 | import { ActorImageType, VideoChannelCreate, VideoChannelUpdate } from '../../../shared' |
6 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 7 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
7 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | 8 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' |
8 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 9 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
@@ -309,20 +310,13 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon | |||
309 | const videoChannelInstance = res.locals.videoChannel | 310 | const videoChannelInstance = res.locals.videoChannel |
310 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined | 311 | const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined |
311 | const countVideos = getCountVideos(req) | 312 | const countVideos = getCountVideos(req) |
312 | const query = req.query as VideosCommonQuery | 313 | const query = pickCommonVideoQuery(req.query) |
313 | 314 | ||
314 | const apiOptions = await Hooks.wrapObject({ | 315 | const apiOptions = await Hooks.wrapObject({ |
316 | ...query, | ||
317 | |||
315 | followerActorId, | 318 | followerActorId, |
316 | start: query.start, | ||
317 | count: query.count, | ||
318 | sort: query.sort, | ||
319 | includeLocalVideos: true, | 319 | includeLocalVideos: true, |
320 | categoryOneOf: query.categoryOneOf, | ||
321 | licenceOneOf: query.licenceOneOf, | ||
322 | languageOneOf: query.languageOneOf, | ||
323 | tagsOneOf: query.tagsOneOf, | ||
324 | tagsAllOf: query.tagsAllOf, | ||
325 | filter: query.filter, | ||
326 | nsfw: buildNSFWFilter(res, query.nsfw), | 320 | nsfw: buildNSFWFilter(res, query.nsfw), |
327 | withFiles: false, | 321 | withFiles: false, |
328 | videoChannelId: videoChannelInstance.id, | 322 | videoChannelId: videoChannelInstance.id, |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 5a2ff81dc..49490f79b 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import toInt from 'validator/lib/toInt' | 2 | import toInt from 'validator/lib/toInt' |
3 | import { pickCommonVideoQuery } from '@server/helpers/query' | ||
3 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { doJSONRequest } from '@server/helpers/requests' |
4 | import { LiveManager } from '@server/lib/live' | 5 | import { LiveManager } from '@server/lib/live' |
5 | import { openapiOperationDoc } from '@server/middlewares/doc' | 6 | import { openapiOperationDoc } from '@server/middlewares/doc' |
6 | import { getServerActor } from '@server/models/application/application' | 7 | import { getServerActor } from '@server/models/application/application' |
7 | import { MVideoAccountLight } from '@server/types/models' | 8 | import { MVideoAccountLight } from '@server/types/models' |
8 | import { VideosCommonQuery } from '../../../../shared' | ||
9 | import { HttpStatusCode } from '../../../../shared/models' | 9 | import { HttpStatusCode } from '../../../../shared/models' |
10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
11 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' | 11 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' |
@@ -211,22 +211,14 @@ async function getVideoFileMetadata (req: express.Request, res: express.Response | |||
211 | } | 211 | } |
212 | 212 | ||
213 | async function listVideos (req: express.Request, res: express.Response) { | 213 | async function listVideos (req: express.Request, res: express.Response) { |
214 | const query = req.query as VideosCommonQuery | 214 | const query = pickCommonVideoQuery(req.query) |
215 | const countVideos = getCountVideos(req) | 215 | const countVideos = getCountVideos(req) |
216 | 216 | ||
217 | const apiOptions = await Hooks.wrapObject({ | 217 | const apiOptions = await Hooks.wrapObject({ |
218 | start: query.start, | 218 | ...query, |
219 | count: query.count, | 219 | |
220 | sort: query.sort, | ||
221 | includeLocalVideos: true, | 220 | includeLocalVideos: true, |
222 | categoryOneOf: query.categoryOneOf, | ||
223 | licenceOneOf: query.licenceOneOf, | ||
224 | languageOneOf: query.languageOneOf, | ||
225 | tagsOneOf: query.tagsOneOf, | ||
226 | tagsAllOf: query.tagsAllOf, | ||
227 | nsfw: buildNSFWFilter(res, query.nsfw), | 221 | nsfw: buildNSFWFilter(res, query.nsfw), |
228 | isLive: query.isLive, | ||
229 | filter: query.filter, | ||
230 | withFiles: false, | 222 | withFiles: false, |
231 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, | 223 | user: res.locals.oauth ? res.locals.oauth.token.User : undefined, |
232 | countVideos | 224 | countVideos |