aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/users.ts2
-rw-r--r--server/controllers/feeds.ts31
-rw-r--r--server/models/video/video.ts4
3 files changed, 22 insertions, 15 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index abe6b3ff7..56cbf9448 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -161,7 +161,7 @@ export {
161 161
162async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 162async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
163 const user = res.locals.oauth.token.User as UserModel 163 const user = res.locals.oauth.token.User as UserModel
164 const resultList = await VideoModel.listUserVideosForApi(user.id ,req.query.start, req.query.count, req.query.sort) 164 const resultList = await VideoModel.listAccountVideosForApi(user.Account.id ,req.query.start, req.query.count, req.query.sort)
165 165
166 return res.json(getFormattedObjects(resultList.data, resultList.total)) 166 return res.json(getFormattedObjects(resultList.data, resultList.total))
167} 167}
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index b9d4c5d50..700c50ec8 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -1,6 +1,12 @@
1import * as express from 'express' 1import * as express from 'express'
2import { CONFIG } from '../initializers' 2import { CONFIG } from '../initializers'
3import { asyncMiddleware, feedsValidator } from '../middlewares' 3import {
4 asyncMiddleware,
5 feedsValidator,
6 setDefaultPagination,
7 setDefaultSort,
8 videosSortValidator
9} from '../middlewares'
4import { VideoModel } from '../models/video/video' 10import { VideoModel } from '../models/video/video'
5import * as Feed from 'pfeed' 11import * as Feed from 'pfeed'
6import { ResultList } from '../../shared/models' 12import { ResultList } from '../../shared/models'
@@ -9,6 +15,8 @@ import { AccountModel } from '../models/account/account'
9const feedsRouter = express.Router() 15const feedsRouter = express.Router()
10 16
11feedsRouter.get('/feeds/videos.:format', 17feedsRouter.get('/feeds/videos.:format',
18 videosSortValidator,
19 setDefaultSort,
12 asyncMiddleware(feedsValidator), 20 asyncMiddleware(feedsValidator),
13 asyncMiddleware(generateFeed) 21 asyncMiddleware(generateFeed)
14) 22)
@@ -23,26 +31,25 @@ export {
23 31
24async function generateFeed (req: express.Request, res: express.Response, next: express.NextFunction) { 32async function generateFeed (req: express.Request, res: express.Response, next: express.NextFunction) {
25 let feed = initFeed() 33 let feed = initFeed()
26 let feedStart = 0 34 const paginationStart = 0
27 let feedCount = 10 35 const paginationCount = 20
28 let feedSort = '-createdAt'
29 36
30 let resultList: ResultList<VideoModel> 37 let resultList: ResultList<VideoModel>
31 const account: AccountModel = res.locals.account 38 const account: AccountModel = res.locals.account
32 39
33 if (account) { 40 if (account) {
34 resultList = await VideoModel.listUserVideosForApi( 41 resultList = await VideoModel.listAccountVideosForApi(
35 account.id, 42 account.id,
36 feedStart, 43 paginationStart,
37 feedCount, 44 paginationCount,
38 feedSort, 45 req.query.sort,
39 true 46 true
40 ) 47 )
41 } else { 48 } else {
42 resultList = await VideoModel.listForApi( 49 resultList = await VideoModel.listForApi(
43 feedStart, 50 paginationStart,
44 feedCount, 51 paginationCount,
45 feedSort, 52 req.query.sort,
46 req.query.filter, 53 req.query.filter,
47 true 54 true
48 ) 55 )
@@ -100,7 +107,7 @@ function initFeed () {
100 rss: `${webserverUrl}/feeds/videos.xml` 107 rss: `${webserverUrl}/feeds/videos.xml`
101 }, 108 },
102 author: { 109 author: {
103 name: 'instance admin of ' + CONFIG.INSTANCE.NAME, 110 name: 'Instance admin of ' + CONFIG.INSTANCE.NAME,
104 email: CONFIG.ADMIN.EMAIL, 111 email: CONFIG.ADMIN.EMAIL,
105 link: `${webserverUrl}/about` 112 link: `${webserverUrl}/about`
106 } 113 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 240a2b5a2..ffb9725b4 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -640,7 +640,7 @@ export class VideoModel extends Model<VideoModel> {
640 }) 640 })
641 } 641 }
642 642
643 static listUserVideosForApi (userId: number, start: number, count: number, sort: string, withFiles = false) { 643 static listAccountVideosForApi (accountId: number, start: number, count: number, sort: string, withFiles = false) {
644 const query: IFindOptions<VideoModel> = { 644 const query: IFindOptions<VideoModel> = {
645 offset: start, 645 offset: start,
646 limit: count, 646 limit: count,
@@ -653,7 +653,7 @@ export class VideoModel extends Model<VideoModel> {
653 { 653 {
654 model: AccountModel, 654 model: AccountModel,
655 where: { 655 where: {
656 userId 656 id: accountId
657 }, 657 },
658 required: true 658 required: true
659 } 659 }