]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-channel.ts
Handle .srt subtitles
[github/Chocobozzz/PeerTube.git] / server / models / video / video-channel.ts
index 8498143fe33b7d5c4781532bbcb0fd68cfd8b326..4251afce994d00ab7999b2fb92420b36b8d7bec1 100644 (file)
@@ -15,6 +15,7 @@ import { ActorModel } from '../activitypub/actor'
 import { getSort, throwIfNotValid } from '../utils'
 import { VideoModel } from './video'
 import { CONSTRAINTS_FIELDS } from '../../initializers'
+import { AvatarModel } from '../avatar/avatar'
 
 enum ScopeNames {
   WITH_ACCOUNT = 'WITH_ACCOUNT',
@@ -34,12 +35,18 @@ enum ScopeNames {
   [ScopeNames.WITH_ACCOUNT]: {
     include: [
       {
-        model: () => AccountModel,
+        model: () => AccountModel.unscoped(),
         required: true,
         include: [
           {
-            model: () => ActorModel,
-            required: true
+            model: () => ActorModel.unscoped(),
+            required: true,
+            include: [
+              {
+                model: () => AvatarModel.unscoped(),
+                required: false
+              }
+            ]
           }
         ]
       }
@@ -237,7 +244,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
     const actor = this.Actor.toFormattedJSON()
     const videoChannel = {
       id: this.id,
-      displayName: this.name,
+      displayName: this.getDisplayName(),
       description: this.description,
       support: this.support,
       isLocal: this.Actor.isOwned(),
@@ -247,12 +254,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       videos: undefined
     }
 
-    if (this.Account) {
-      videoChannel.ownerAccount = {
-        id: this.Account.id,
-        uuid: this.Account.Actor.uuid
-      }
-    }
+    if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()
 
     return Object.assign(actor, videoChannel)
   }
@@ -271,4 +273,8 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
       ]
     })
   }
+
+  getDisplayName () {
+    return this.name
+  }
 }