aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/accounts.ts27
-rw-r--r--server/controllers/api/users/me.ts3
-rw-r--r--server/controllers/api/users/my-subscriptions.ts23
-rw-r--r--server/controllers/api/video-channel.ts23
-rw-r--r--server/controllers/api/videos/index.ts25
5 files changed, 54 insertions, 47 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index e31924a94..49a8e3195 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -1,9 +1,10 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getServerActor } from '@server/models/application/application' 2import { getServerActor } from '@server/models/application/application'
3import { VideosWithSearchCommonQuery } from '@shared/models'
3import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 4import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
4import { getFormattedObjects } from '../../helpers/utils' 5import { getFormattedObjects } from '../../helpers/utils'
5import { Hooks } from '../../lib/plugins/hooks'
6import { JobQueue } from '../../lib/job-queue' 6import { JobQueue } from '../../lib/job-queue'
7import { Hooks } from '../../lib/plugins/hooks'
7import { 8import {
8 asyncMiddleware, 9 asyncMiddleware,
9 authenticate, 10 authenticate,
@@ -158,25 +159,27 @@ async function listAccountVideos (req: express.Request, res: express.Response) {
158 const account = res.locals.account 159 const account = res.locals.account
159 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 160 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
160 const countVideos = getCountVideos(req) 161 const countVideos = getCountVideos(req)
162 const query = req.query as VideosWithSearchCommonQuery
161 163
162 const apiOptions = await Hooks.wrapObject({ 164 const apiOptions = await Hooks.wrapObject({
163 followerActorId, 165 followerActorId,
164 start: req.query.start, 166 start: query.start,
165 count: req.query.count, 167 count: query.count,
166 sort: req.query.sort, 168 sort: query.sort,
167 includeLocalVideos: true, 169 includeLocalVideos: true,
168 categoryOneOf: req.query.categoryOneOf, 170 categoryOneOf: query.categoryOneOf,
169 licenceOneOf: req.query.licenceOneOf, 171 licenceOneOf: query.licenceOneOf,
170 languageOneOf: req.query.languageOneOf, 172 languageOneOf: query.languageOneOf,
171 tagsOneOf: req.query.tagsOneOf, 173 tagsOneOf: query.tagsOneOf,
172 tagsAllOf: req.query.tagsAllOf, 174 tagsAllOf: query.tagsAllOf,
173 filter: req.query.filter, 175 filter: query.filter,
174 nsfw: buildNSFWFilter(res, req.query.nsfw), 176 isLive: query.isLive,
177 nsfw: buildNSFWFilter(res, query.nsfw),
175 withFiles: false, 178 withFiles: false,
176 accountId: account.id, 179 accountId: account.id,
177 user: res.locals.oauth ? res.locals.oauth.token.User : undefined, 180 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
178 countVideos, 181 countVideos,
179 search: req.query.search 182 search: query.search
180 }, 'filter:api.accounts.videos.list.params') 183 }, 'filter:api.accounts.videos.list.params')
181 184
182 const resultList = await Hooks.wrapPromiseFun( 185 const resultList = await Hooks.wrapPromiseFun(
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index 9f9d2d77f..0763d1900 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -111,7 +111,8 @@ async function getUserVideos (req: express.Request, res: express.Response) {
111 start: req.query.start, 111 start: req.query.start,
112 count: req.query.count, 112 count: req.query.count,
113 sort: req.query.sort, 113 sort: req.query.sort,
114 search: req.query.search 114 search: req.query.search,
115 isLive: req.query.isLive
115 }, 'filter:api.user.me.videos.list.params') 116 }, 'filter:api.user.me.videos.list.params')
116 117
117 const resultList = await Hooks.wrapPromiseFun( 118 const resultList = await Hooks.wrapPromiseFun(
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index e8949ee59..56b93276f 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -2,8 +2,8 @@ import 'multer'
2import * as express from 'express' 2import * as express from 'express'
3import { sendUndoFollow } from '@server/lib/activitypub/send' 3import { sendUndoFollow } from '@server/lib/activitypub/send'
4import { VideoChannelModel } from '@server/models/video/video-channel' 4import { VideoChannelModel } from '@server/models/video/video-channel'
5import { VideosCommonQuery } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
7import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' 7import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
8import { getFormattedObjects } from '../../../helpers/utils' 8import { getFormattedObjects } from '../../../helpers/utils'
9import { WEBSERVER } from '../../../initializers/constants' 9import { WEBSERVER } from '../../../initializers/constants'
@@ -170,19 +170,20 @@ async function getUserSubscriptions (req: express.Request, res: express.Response
170async function getUserSubscriptionVideos (req: express.Request, res: express.Response) { 170async 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 174
174 const resultList = await VideoModel.listForApi({ 175 const resultList = await VideoModel.listForApi({
175 start: req.query.start, 176 start: query.start,
176 count: req.query.count, 177 count: query.count,
177 sort: req.query.sort, 178 sort: query.sort,
178 includeLocalVideos: false, 179 includeLocalVideos: false,
179 categoryOneOf: req.query.categoryOneOf, 180 categoryOneOf: query.categoryOneOf,
180 licenceOneOf: req.query.licenceOneOf, 181 licenceOneOf: query.licenceOneOf,
181 languageOneOf: req.query.languageOneOf, 182 languageOneOf: query.languageOneOf,
182 tagsOneOf: req.query.tagsOneOf, 183 tagsOneOf: query.tagsOneOf,
183 tagsAllOf: req.query.tagsAllOf, 184 tagsAllOf: query.tagsAllOf,
184 nsfw: buildNSFWFilter(res, req.query.nsfw), 185 nsfw: buildNSFWFilter(res, query.nsfw),
185 filter: req.query.filter as VideoFilter, 186 filter: query.filter,
186 withFiles: false, 187 withFiles: false,
187 followerActorId: user.Account.Actor.id, 188 followerActorId: user.Account.Actor.id,
188 user, 189 user,
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 149d6cfb4..a755d7e57 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { Hooks } from '@server/lib/plugins/hooks' 2import { Hooks } from '@server/lib/plugins/hooks'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { MChannelBannerAccountDefault } from '@server/types/models' 4import { MChannelBannerAccountDefault } from '@server/types/models'
5import { ActorImageType, VideoChannelCreate, VideoChannelUpdate } from '../../../shared' 5import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared'
6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
7import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' 7import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
8import { resetSequelizeInstance } from '../../helpers/database-utils' 8import { resetSequelizeInstance } from '../../helpers/database-utils'
@@ -312,20 +312,21 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon
312 const videoChannelInstance = res.locals.videoChannel 312 const videoChannelInstance = res.locals.videoChannel
313 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 313 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
314 const countVideos = getCountVideos(req) 314 const countVideos = getCountVideos(req)
315 const query = req.query as VideosCommonQuery
315 316
316 const apiOptions = await Hooks.wrapObject({ 317 const apiOptions = await Hooks.wrapObject({
317 followerActorId, 318 followerActorId,
318 start: req.query.start, 319 start: query.start,
319 count: req.query.count, 320 count: query.count,
320 sort: req.query.sort, 321 sort: query.sort,
321 includeLocalVideos: true, 322 includeLocalVideos: true,
322 categoryOneOf: req.query.categoryOneOf, 323 categoryOneOf: query.categoryOneOf,
323 licenceOneOf: req.query.licenceOneOf, 324 licenceOneOf: query.licenceOneOf,
324 languageOneOf: req.query.languageOneOf, 325 languageOneOf: query.languageOneOf,
325 tagsOneOf: req.query.tagsOneOf, 326 tagsOneOf: query.tagsOneOf,
326 tagsAllOf: req.query.tagsAllOf, 327 tagsAllOf: query.tagsAllOf,
327 filter: req.query.filter, 328 filter: query.filter,
328 nsfw: buildNSFWFilter(res, req.query.nsfw), 329 nsfw: buildNSFWFilter(res, query.nsfw),
329 withFiles: false, 330 withFiles: false,
330 videoChannelId: videoChannelInstance.id, 331 videoChannelId: videoChannelInstance.id,
331 user: res.locals.oauth ? res.locals.oauth.token.User : undefined, 332 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 7fee278f2..6ec6478e4 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -10,9 +10,8 @@ import { addOptimizeOrMergeAudioJob, buildLocalVideoFromReq, buildVideoThumbnail
10import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths' 10import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
11import { getServerActor } from '@server/models/application/application' 11import { getServerActor } from '@server/models/application/application'
12import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' 12import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
13import { VideoCreate, VideoState, VideoUpdate } from '../../../../shared' 13import { VideoCreate, VideosCommonQuery, VideoState, VideoUpdate } from '../../../../shared'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
15import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
16import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 15import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
17import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers/database-utils' 16import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers/database-utils'
18import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils' 17import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils'
@@ -494,20 +493,22 @@ async function getVideoFileMetadata (req: express.Request, res: express.Response
494} 493}
495 494
496async function listVideos (req: express.Request, res: express.Response) { 495async function listVideos (req: express.Request, res: express.Response) {
496 const query = req.query as VideosCommonQuery
497 const countVideos = getCountVideos(req) 497 const countVideos = getCountVideos(req)
498 498
499 const apiOptions = await Hooks.wrapObject({ 499 const apiOptions = await Hooks.wrapObject({
500 start: req.query.start, 500 start: query.start,
501 count: req.query.count, 501 count: query.count,
502 sort: req.query.sort, 502 sort: query.sort,
503 includeLocalVideos: true, 503 includeLocalVideos: true,
504 categoryOneOf: req.query.categoryOneOf, 504 categoryOneOf: query.categoryOneOf,
505 licenceOneOf: req.query.licenceOneOf, 505 licenceOneOf: query.licenceOneOf,
506 languageOneOf: req.query.languageOneOf, 506 languageOneOf: query.languageOneOf,
507 tagsOneOf: req.query.tagsOneOf, 507 tagsOneOf: query.tagsOneOf,
508 tagsAllOf: req.query.tagsAllOf, 508 tagsAllOf: query.tagsAllOf,
509 nsfw: buildNSFWFilter(res, req.query.nsfw), 509 nsfw: buildNSFWFilter(res, query.nsfw),
510 filter: req.query.filter as VideoFilter, 510 isLive: query.isLive,
511 filter: query.filter,
511 withFiles: false, 512 withFiles: false,
512 user: res.locals.oauth ? res.locals.oauth.token.User : undefined, 513 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
513 countVideos 514 countVideos