aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/accounts.ts6
-rw-r--r--server/controllers/api/overviews.ts5
-rw-r--r--server/controllers/api/users/my-subscriptions.ts7
-rw-r--r--server/controllers/api/video-channel.ts6
-rw-r--r--server/controllers/api/videos/index.ts7
-rw-r--r--server/controllers/bots.ts7
6 files changed, 25 insertions, 13 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index c49da3c0a..00148ff55 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -22,7 +22,7 @@ import {
22import { AccountModel } from '../../models/account/account' 22import { AccountModel } from '../../models/account/account'
23import { AccountVideoRateModel } from '../../models/account/account-video-rate' 23import { AccountVideoRateModel } from '../../models/account/account-video-rate'
24import { VideoModel } from '../../models/video/video' 24import { VideoModel } from '../../models/video/video'
25import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 25import { buildNSFWFilter, isUserAbleToSearchRemoteURI, getCountVideos } from '../../helpers/express-utils'
26import { VideoChannelModel } from '../../models/video/video-channel' 26import { VideoChannelModel } from '../../models/video/video-channel'
27import { JobQueue } from '../../lib/job-queue' 27import { JobQueue } from '../../lib/job-queue'
28import { logger } from '../../helpers/logger' 28import { logger } from '../../helpers/logger'
@@ -155,6 +155,7 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
155async function listAccountVideos (req: express.Request, res: express.Response) { 155async function listAccountVideos (req: express.Request, res: express.Response) {
156 const account = res.locals.account 156 const account = res.locals.account
157 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 157 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
158 const countVideos = getCountVideos(req)
158 159
159 const resultList = await VideoModel.listForApi({ 160 const resultList = await VideoModel.listForApi({
160 followerActorId, 161 followerActorId,
@@ -171,7 +172,8 @@ async function listAccountVideos (req: express.Request, res: express.Response) {
171 nsfw: buildNSFWFilter(res, req.query.nsfw), 172 nsfw: buildNSFWFilter(res, req.query.nsfw),
172 withFiles: false, 173 withFiles: false,
173 accountId: account.id, 174 accountId: account.id,
174 user: res.locals.oauth ? res.locals.oauth.token.User : undefined 175 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
176 countVideos
175 }) 177 })
176 178
177 return res.json(getFormattedObjects(resultList.data, resultList.total)) 179 return res.json(getFormattedObjects(resultList.data, resultList.total))
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index 37ac152db..23706767a 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -98,10 +98,11 @@ async function getVideos (
98 sort: '-createdAt', 98 sort: '-createdAt',
99 includeLocalVideos: true, 99 includeLocalVideos: true,
100 nsfw: buildNSFWFilter(res), 100 nsfw: buildNSFWFilter(res),
101 withFiles: false 101 withFiles: false,
102 countVideos: false
102 }, where) 103 }, where)
103 104
104 const { data } = await VideoModel.listForApi(query, false) 105 const { data } = await VideoModel.listForApi(query)
105 106
106 return data.map(d => d.toFormattedJSON()) 107 return data.map(d => d.toFormattedJSON())
107} 108}
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index c52df3154..43c4c37d8 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -15,7 +15,7 @@ import {
15} from '../../../middlewares' 15} from '../../../middlewares'
16import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators' 16import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators'
17import { VideoModel } from '../../../models/video/video' 17import { VideoModel } from '../../../models/video/video'
18import { buildNSFWFilter } from '../../../helpers/express-utils' 18import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
19import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 19import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
20import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 20import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
21import { JobQueue } from '../../../lib/job-queue' 21import { JobQueue } from '../../../lib/job-queue'
@@ -149,6 +149,8 @@ async function getUserSubscriptions (req: express.Request, res: express.Response
149 149
150async function getUserSubscriptionVideos (req: express.Request, res: express.Response) { 150async function getUserSubscriptionVideos (req: express.Request, res: express.Response) {
151 const user = res.locals.oauth.token.User 151 const user = res.locals.oauth.token.User
152 const countVideos = getCountVideos(req)
153
152 const resultList = await VideoModel.listForApi({ 154 const resultList = await VideoModel.listForApi({
153 start: req.query.start, 155 start: req.query.start,
154 count: req.query.count, 156 count: req.query.count,
@@ -163,7 +165,8 @@ async function getUserSubscriptionVideos (req: express.Request, res: express.Res
163 filter: req.query.filter as VideoFilter, 165 filter: req.query.filter as VideoFilter,
164 withFiles: false, 166 withFiles: false,
165 followerActorId: user.Account.Actor.id, 167 followerActorId: user.Account.Actor.id,
166 user 168 user,
169 countVideos
167 }) 170 })
168 171
169 return res.json(getFormattedObjects(resultList.data, resultList.total)) 172 return res.json(getFormattedObjects(resultList.data, resultList.total))
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index acc5b2987..e1f37a8fb 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -20,7 +20,7 @@ import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../m
20import { sendUpdateActor } from '../../lib/activitypub/send' 20import { sendUpdateActor } from '../../lib/activitypub/send'
21import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' 21import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared'
22import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' 22import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'
23import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 23import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
24import { setAsyncActorKeys } from '../../lib/activitypub' 24import { setAsyncActorKeys } from '../../lib/activitypub'
25import { AccountModel } from '../../models/account/account' 25import { AccountModel } from '../../models/account/account'
26import { MIMETYPES } from '../../initializers/constants' 26import { MIMETYPES } from '../../initializers/constants'
@@ -256,6 +256,7 @@ async function listVideoChannelPlaylists (req: express.Request, res: express.Res
256async function listVideoChannelVideos (req: express.Request, res: express.Response) { 256async function listVideoChannelVideos (req: express.Request, res: express.Response) {
257 const videoChannelInstance = res.locals.videoChannel 257 const videoChannelInstance = res.locals.videoChannel
258 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 258 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
259 const countVideos = getCountVideos(req)
259 260
260 const resultList = await VideoModel.listForApi({ 261 const resultList = await VideoModel.listForApi({
261 followerActorId, 262 followerActorId,
@@ -272,7 +273,8 @@ async function listVideoChannelVideos (req: express.Request, res: express.Respon
272 nsfw: buildNSFWFilter(res, req.query.nsfw), 273 nsfw: buildNSFWFilter(res, req.query.nsfw),
273 withFiles: false, 274 withFiles: false,
274 videoChannelId: videoChannelInstance.id, 275 videoChannelId: videoChannelInstance.id,
275 user: res.locals.oauth ? res.locals.oauth.token.User : undefined 276 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
277 countVideos
276 }) 278 })
277 279
278 return res.json(getFormattedObjects(resultList.data, resultList.total)) 280 return res.json(getFormattedObjects(resultList.data, resultList.total))
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 35f0b3152..8d4ff07eb 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -48,7 +48,7 @@ import { videoCommentRouter } from './comment'
48import { rateVideoRouter } from './rate' 48import { rateVideoRouter } from './rate'
49import { ownershipVideoRouter } from './ownership' 49import { ownershipVideoRouter } from './ownership'
50import { VideoFilter } from '../../../../shared/models/videos/video-query.type' 50import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
51import { buildNSFWFilter, createReqFiles } from '../../../helpers/express-utils' 51import { buildNSFWFilter, createReqFiles, getCountVideos } from '../../../helpers/express-utils'
52import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 52import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
53import { videoCaptionsRouter } from './captions' 53import { videoCaptionsRouter } from './captions'
54import { videoImportsRouter } from './import' 54import { videoImportsRouter } from './import'
@@ -495,6 +495,8 @@ async function getVideoDescription (req: express.Request, res: express.Response)
495} 495}
496 496
497async function listVideos (req: express.Request, res: express.Response) { 497async function listVideos (req: express.Request, res: express.Response) {
498 const countVideos = getCountVideos(req)
499
498 const apiOptions = await Hooks.wrapObject({ 500 const apiOptions = await Hooks.wrapObject({
499 start: req.query.start, 501 start: req.query.start,
500 count: req.query.count, 502 count: req.query.count,
@@ -508,7 +510,8 @@ async function listVideos (req: express.Request, res: express.Response) {
508 nsfw: buildNSFWFilter(res, req.query.nsfw), 510 nsfw: buildNSFWFilter(res, req.query.nsfw),
509 filter: req.query.filter as VideoFilter, 511 filter: req.query.filter as VideoFilter,
510 withFiles: false, 512 withFiles: false,
511 user: res.locals.oauth ? res.locals.oauth.token.User : undefined 513 user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
514 countVideos
512 }, 'filter:api.videos.list.params') 515 }, 'filter:api.videos.list.params')
513 516
514 const resultList = await Hooks.wrapPromiseFun( 517 const resultList = await Hooks.wrapPromiseFun(
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index ed1040176..f3e778b04 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -61,17 +61,18 @@ async function getSitemapAccountUrls () {
61} 61}
62 62
63async function getSitemapLocalVideoUrls () { 63async function getSitemapLocalVideoUrls () {
64 const resultList = await VideoModel.listForApi({ 64 const { data } = await VideoModel.listForApi({
65 start: 0, 65 start: 0,
66 count: undefined, 66 count: undefined,
67 sort: 'createdAt', 67 sort: 'createdAt',
68 includeLocalVideos: true, 68 includeLocalVideos: true,
69 nsfw: buildNSFWFilter(), 69 nsfw: buildNSFWFilter(),
70 filter: 'local', 70 filter: 'local',
71 withFiles: false 71 withFiles: false,
72 countVideos: false
72 }) 73 })
73 74
74 return resultList.data.map(v => ({ 75 return data.map(v => ({
75 url: WEBSERVER.URL + '/videos/watch/' + v.uuid, 76 url: WEBSERVER.URL + '/videos/watch/' + v.uuid,
76 video: [ 77 video: [
77 { 78 {