]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-channel.ts
Merge branch 'develop' into pr/1217
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel.ts
index e70e525153c0351bf40bfd7bc6f2ff89d2402132..5598d80f615fe53f4ede030caf28b251ab55c42c 100644 (file)
@@ -71,7 +71,7 @@ type AvailableForListOptions = {
     const inQueryInstanceFollow = '(' +
       'SELECT "actor"."serverId" FROM "actorFollow" ' +
       'INNER JOIN "actor" ON actor.id=  "actorFollow"."targetActorId" ' +
-      'WHERE "actor"."id" = ' + actorIdNumber +
+      'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
     ')'
 
     return {
@@ -233,6 +233,27 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       })
   }
 
+  static listLocalsForSitemap (sort: string) {
+    const query = {
+      attributes: [ ],
+      offset: 0,
+      order: getSort(sort),
+      include: [
+        {
+          attributes: [ 'preferredUsername', 'serverId' ],
+          model: ActorModel.unscoped(),
+          where: {
+            serverId: null
+          }
+        }
+      ]
+    }
+
+    return VideoChannelModel
+      .unscoped()
+      .findAll(query)
+  }
+
   static searchForApi (options: {
     actorId: number
     search: string
@@ -296,6 +317,12 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       })
   }
 
+  static loadByIdAndPopulateAccount (id: number) {
+    return VideoChannelModel.unscoped()
+      .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
+      .findById(id)
+  }
+
   static loadByIdAndAccount (id: number, accountId: number) {
     const query = {
       where: {
@@ -304,13 +331,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       }
     }
 
-    return VideoChannelModel
+    return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
       .findOne(query)
   }
 
   static loadAndPopulateAccount (id: number) {
-    return VideoChannelModel
+    return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
       .findById(id)
   }
@@ -365,7 +392,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       ]
     }
 
-    return VideoChannelModel
+    return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
       .findOne(query)
   }
@@ -390,7 +417,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       ]
     }
 
-    return VideoChannelModel
+    return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
       .findOne(query)
   }
@@ -402,7 +429,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       ]
     }
 
-    return VideoChannelModel
+    return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEOS ])
       .findById(id, options)
   }
@@ -443,4 +470,8 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
   getDisplayName () {
     return this.name
   }
+
+  isOutdated () {
+    return this.Actor.isOutdated()
+  }
 }