aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 17:19:00 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 17:29:19 +0200
commit8519cc92341545468104f0704fff64a05c84bec0 (patch)
treede67ec4981ae2ce74d7a12c1adad5883f90fc7f5
parent9ce3d3027ed7253fbd4fe46787eda58c51549444 (diff)
downloadPeerTube-8519cc92341545468104f0704fff64a05c84bec0.tar.gz
PeerTube-8519cc92341545468104f0704fff64a05c84bec0.tar.zst
PeerTube-8519cc92341545468104f0704fff64a05c84bec0.zip
Fix overview endpoint
-rw-r--r--.travis.yml2
-rw-r--r--server/middlewares/cache.ts3
-rw-r--r--server/models/video/video.ts9
-rw-r--r--server/tests/api/check-params/contact-form.ts2
-rw-r--r--server/tests/api/videos/video-playlists.ts11
5 files changed, 17 insertions, 10 deletions
diff --git a/.travis.yml b/.travis.yml
index 8d61fc10f..5fa41fb43 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,7 +47,7 @@ matrix:
47 - env: TEST_SUITE=lint 47 - env: TEST_SUITE=lint
48 48
49script: 49script:
50 - NODE_PENDING_JOB_WAIT=1000 travis_retry npm run travis -- "$TEST_SUITE" 50 - NODE_PENDING_JOB_WAIT=2000 travis_retry npm run travis -- "$TEST_SUITE"
51 51
52after_failure: 52after_failure:
53 - cat test1/logs/peertube.log 53 - cat test1/logs/peertube.log
diff --git a/server/middlewares/cache.ts b/server/middlewares/cache.ts
index e83d8d569..091c82d92 100644
--- a/server/middlewares/cache.ts
+++ b/server/middlewares/cache.ts
@@ -7,6 +7,8 @@ import { logger } from '../helpers/logger'
7const lock = new AsyncLock({ timeout: 5000 }) 7const lock = new AsyncLock({ timeout: 5000 })
8 8
9function cacheRoute (lifetimeArg: string | number) { 9function cacheRoute (lifetimeArg: string | number) {
10 const lifetime = parseDurationToMs(lifetimeArg)
11
10 return async function (req: express.Request, res: express.Response, next: express.NextFunction) { 12 return async function (req: express.Request, res: express.Response, next: express.NextFunction) {
11 const redisKey = Redis.Instance.generateCachedRouteKey(req) 13 const redisKey = Redis.Instance.generateCachedRouteKey(req)
12 14
@@ -24,7 +26,6 @@ function cacheRoute (lifetimeArg: string | number) {
24 res.send = (body) => { 26 res.send = (body) => {
25 if (res.statusCode >= 200 && res.statusCode < 400) { 27 if (res.statusCode >= 200 && res.statusCode < 400) {
26 const contentType = res.get('content-type') 28 const contentType = res.get('content-type')
27 const lifetime = parseDurationToMs(lifetimeArg)
28 29
29 Redis.Instance.setCachedRoute(req, body, lifetime, contentType, res.statusCode) 30 Redis.Instance.setCachedRoute(req, body, lifetime, contentType, res.statusCode)
30 .then(() => done()) 31 .then(() => done())
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 5fb529e8d..4e6f602aa 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -207,6 +207,8 @@ type AvailableForListIDsOptions = {
207 followerActorId: number 207 followerActorId: number
208 includeLocalVideos: boolean 208 includeLocalVideos: boolean
209 209
210 withoutId?: boolean
211
210 filter?: VideoFilter 212 filter?: VideoFilter
211 categoryOneOf?: number[] 213 categoryOneOf?: number[]
212 nsfw?: boolean 214 nsfw?: boolean
@@ -268,9 +270,11 @@ type AvailableForListIDsOptions = {
268 return query 270 return query
269 }, 271 },
270 [ ScopeNames.AVAILABLE_FOR_LIST_IDS ]: (options: AvailableForListIDsOptions) => { 272 [ ScopeNames.AVAILABLE_FOR_LIST_IDS ]: (options: AvailableForListIDsOptions) => {
273 const attributes = options.withoutId === true ? [] : [ 'id' ]
274
271 const query: FindOptions = { 275 const query: FindOptions = {
272 raw: true, 276 raw: true,
273 attributes: [ 'id' ], 277 attributes,
274 where: { 278 where: {
275 id: { 279 id: {
276 [ Op.and ]: [ 280 [ Op.and ]: [
@@ -1523,7 +1527,8 @@ export class VideoModel extends Model<VideoModel> {
1523 const scopeOptions: AvailableForListIDsOptions = { 1527 const scopeOptions: AvailableForListIDsOptions = {
1524 serverAccountId: serverActor.Account.id, 1528 serverAccountId: serverActor.Account.id,
1525 followerActorId, 1529 followerActorId,
1526 includeLocalVideos: true 1530 includeLocalVideos: true,
1531 withoutId: true // Don't break aggregation
1527 } 1532 }
1528 1533
1529 const query: FindOptions = { 1534 const query: FindOptions = {
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 55004020f..dbdd3a8a6 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -87,6 +87,6 @@ describe('Test contact form API validators', function () {
87 after(async function () { 87 after(async function () {
88 MockSmtpServer.Instance.kill() 88 MockSmtpServer.Instance.kill()
89 89
90 // await cleanupTests([ server ]) 90 await cleanupTests([ server ])
91 }) 91 })
92}) 92})
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 928568299..e4d817ff8 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -5,23 +5,24 @@ import 'mocha'
5import { 5import {
6 addVideoChannel, 6 addVideoChannel,
7 addVideoInPlaylist, 7 addVideoInPlaylist,
8 checkPlaylistFilesWereRemoved, cleanupTests, 8 checkPlaylistFilesWereRemoved,
9 cleanupTests,
9 createUser, 10 createUser,
10 createVideoPlaylist, 11 createVideoPlaylist,
11 deleteVideoChannel, 12 deleteVideoChannel,
12 deleteVideoPlaylist, 13 deleteVideoPlaylist,
13 doubleFollow, doVideosExistInMyPlaylist, 14 doubleFollow,
15 doVideosExistInMyPlaylist,
14 flushAndRunMultipleServers, 16 flushAndRunMultipleServers,
15 flushTests,
16 getAccountPlaylistsList, 17 getAccountPlaylistsList,
17 getAccountPlaylistsListWithToken, getMyUserInformation, 18 getAccountPlaylistsListWithToken,
19 getMyUserInformation,
18 getPlaylistVideos, 20 getPlaylistVideos,
19 getVideoChannelPlaylistsList, 21 getVideoChannelPlaylistsList,
20 getVideoPlaylist, 22 getVideoPlaylist,
21 getVideoPlaylistPrivacies, 23 getVideoPlaylistPrivacies,
22 getVideoPlaylistsList, 24 getVideoPlaylistsList,
23 getVideoPlaylistWithToken, 25 getVideoPlaylistWithToken,
24 killallServers,
25 removeUser, 26 removeUser,
26 removeVideoFromPlaylist, 27 removeVideoFromPlaylist,
27 reorderVideosPlaylist, 28 reorderVideosPlaylist,