]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video.ts
Add notification on new instance follower (server side)
[github/Chocobozzz/PeerTube.git] / server / models / video / video.ts
index 06c63e87c42a0a372e3c372230d9f4bdde1e98b8..b0d92b674ccc0bf310ae051c5fb1dd4e9d2d707c 100644 (file)
@@ -77,7 +77,7 @@ import {
   buildTrigramSearchIndex,
   buildWhereIdOrUUID,
   createSimilarityAttribute,
-  getVideoSort,
+  getVideoSort, isOutdated,
   throwIfNotValid
 } from '../utils'
 import { TagModel } from './tag'
@@ -225,7 +225,8 @@ type AvailableForListIDsOptions = {
       },
       include: [
         {
-          model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] })
+          model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] }),
+          required: true
         }
       ]
     }
@@ -240,7 +241,10 @@ type AvailableForListIDsOptions = {
     if (options.videoPlaylistId) {
       query.include.push({
         model: VideoPlaylistElementModel.unscoped(),
-        required: true
+        required: true,
+        where: {
+          videoPlaylistId: options.videoPlaylistId
+        }
       })
     }
 
@@ -304,6 +308,8 @@ type AvailableForListIDsOptions = {
           videoPlaylistId: options.videoPlaylistId
         }
       })
+
+      query.subQuery = false
     }
 
     if (options.filter || options.accountId || options.videoChannelId) {
@@ -1561,8 +1567,8 @@ export class VideoModel extends Model<VideoModel> {
     apiScope.push({
       method: [
         ScopeNames.FOR_API, {
-          ids, withFiles:
-          options.withFiles,
+          ids,
+          withFiles: options.withFiles,
           videoPlaylistId: options.videoPlaylistId
         } as ForAPIOptions
       ]
@@ -1761,12 +1767,7 @@ export class VideoModel extends Model<VideoModel> {
   isOutdated () {
     if (this.isOwned()) return false
 
-    const now = Date.now()
-    const createdAtTime = this.createdAt.getTime()
-    const updatedAtTime = this.updatedAt.getTime()
-
-    return (now - createdAtTime) > ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL &&
-      (now - updatedAtTime) > ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL
+    return isOutdated(this, ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL)
   }
 
   setAsRefreshed () {