]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-channel.ts
Ensure we don't run transcoding after import file
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel.ts
index 278149d60751ed6bd7b732307ce0a67ee8c016c3..b652d8531aab6a60a9dfe1379827e0e040346c37 100644 (file)
@@ -44,6 +44,7 @@ import { setAsUpdated } from '../shared'
 import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
 import { VideoModel } from './video'
 import { VideoPlaylistModel } from './video-playlist'
+import { CONFIG } from '@server/initializers/config'
 
 export enum ScopeNames {
   FOR_API = 'FOR_API',
@@ -121,7 +122,7 @@ export type SummaryOptions = {
       for (const handle of options.handles || []) {
         const [ preferredUsername, host ] = handle.split('@')
 
-        if (!host) {
+        if (!host || host === WEBSERVER.HOST) {
           or.push({
             '$Actor.preferredUsername$': preferredUsername,
             '$Actor.serverId$': null
@@ -527,7 +528,7 @@ ON              "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
       })
   }
 
-  static listByAccount (options: {
+  static listByAccountForAPI (options: {
     accountId: number
     start: number
     count: number
@@ -582,6 +583,24 @@ ON              "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
       })
   }
 
+  static listAllByAccount (accountId: number) {
+    const query = {
+      limit: CONFIG.VIDEO_CHANNELS.MAX_PER_USER,
+      include: [
+        {
+          attributes: [],
+          model: AccountModel,
+          where: {
+            id: accountId
+          },
+          required: true
+        }
+      ]
+    }
+
+    return VideoChannelModel.findAll(query)
+  }
+
   static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise<MChannelBannerAccountDefault> {
     return VideoChannelModel.unscoped()
       .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])
@@ -753,7 +772,7 @@ ON              "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
     return this.Actor.isOutdated()
   }
 
-  setAsUpdated (transaction: Transaction) {
+  setAsUpdated (transaction?: Transaction) {
     return setAsUpdated('videoChannel', this.id, transaction)
   }
 }