Browse Source

Fix overview endpoint

Chocobozzz 4 years ago
parent
commit
8519cc9234

+ 1 - 1
.travis.yml

@@ -47,7 +47,7 @@ matrix:
   - env: TEST_SUITE=lint
 
 script:
-  - NODE_PENDING_JOB_WAIT=1000 travis_retry npm run travis -- "$TEST_SUITE"
+  - NODE_PENDING_JOB_WAIT=2000 travis_retry npm run travis -- "$TEST_SUITE"
 
 after_failure:
   - cat test1/logs/peertube.log

+ 2 - 1
server/middlewares/cache.ts

@@ -7,6 +7,8 @@ import { logger } from '../helpers/logger'
 const lock = new AsyncLock({ timeout: 5000 })
 
 function cacheRoute (lifetimeArg: string | number) {
+  const lifetime = parseDurationToMs(lifetimeArg)
+
   return async function (req: express.Request, res: express.Response, next: express.NextFunction) {
     const redisKey = Redis.Instance.generateCachedRouteKey(req)
 
@@ -24,7 +26,6 @@ function cacheRoute (lifetimeArg: string | number) {
           res.send = (body) => {
             if (res.statusCode >= 200 && res.statusCode < 400) {
               const contentType = res.get('content-type')
-              const lifetime = parseDurationToMs(lifetimeArg)
 
               Redis.Instance.setCachedRoute(req, body, lifetime, contentType, res.statusCode)
                    .then(() => done())

+ 7 - 2
server/models/video/video.ts

@@ -207,6 +207,8 @@ type AvailableForListIDsOptions = {
   followerActorId: number
   includeLocalVideos: boolean
 
+  withoutId?: boolean
+
   filter?: VideoFilter
   categoryOneOf?: number[]
   nsfw?: boolean
@@ -268,9 +270,11 @@ type AvailableForListIDsOptions = {
     return query
   },
   [ ScopeNames.AVAILABLE_FOR_LIST_IDS ]: (options: AvailableForListIDsOptions) => {
+    const attributes = options.withoutId === true ? [] : [ 'id' ]
+
     const query: FindOptions = {
       raw: true,
-      attributes: [ 'id' ],
+      attributes,
       where: {
         id: {
           [ Op.and ]: [
@@ -1523,7 +1527,8 @@ export class VideoModel extends Model<VideoModel> {
     const scopeOptions: AvailableForListIDsOptions = {
       serverAccountId: serverActor.Account.id,
       followerActorId,
-      includeLocalVideos: true
+      includeLocalVideos: true,
+      withoutId: true // Don't break aggregation
     }
 
     const query: FindOptions = {

+ 1 - 1
server/tests/api/check-params/contact-form.ts

@@ -87,6 +87,6 @@ describe('Test contact form API validators', function () {
   after(async function () {
     MockSmtpServer.Instance.kill()
 
-    // await cleanupTests([ server ])
+    await cleanupTests([ server ])
   })
 })

+ 6 - 5
server/tests/api/videos/video-playlists.ts

@@ -5,23 +5,24 @@ import 'mocha'
 import {
   addVideoChannel,
   addVideoInPlaylist,
-  checkPlaylistFilesWereRemoved, cleanupTests,
+  checkPlaylistFilesWereRemoved,
+  cleanupTests,
   createUser,
   createVideoPlaylist,
   deleteVideoChannel,
   deleteVideoPlaylist,
-  doubleFollow, doVideosExistInMyPlaylist,
+  doubleFollow,
+  doVideosExistInMyPlaylist,
   flushAndRunMultipleServers,
-  flushTests,
   getAccountPlaylistsList,
-  getAccountPlaylistsListWithToken, getMyUserInformation,
+  getAccountPlaylistsListWithToken,
+  getMyUserInformation,
   getPlaylistVideos,
   getVideoChannelPlaylistsList,
   getVideoPlaylist,
   getVideoPlaylistPrivacies,
   getVideoPlaylistsList,
   getVideoPlaylistWithToken,
-  killallServers,
   removeUser,
   removeVideoFromPlaylist,
   reorderVideosPlaylist,