aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-channel.ts17
-rw-r--r--server/models/video/video.ts11
2 files changed, 21 insertions, 7 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 40f3be7fe..4a50af265 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -108,7 +108,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
108 foreignKey: { 108 foreignKey: {
109 allowNull: false 109 allowNull: false
110 }, 110 },
111 onDelete: 'CASCADE' 111 hooks: true
112 }) 112 })
113 Account: AccountModel 113 Account: AccountModel
114 114
@@ -234,17 +234,26 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
234 234
235 toFormattedJSON (): VideoChannel { 235 toFormattedJSON (): VideoChannel {
236 const actor = this.Actor.toFormattedJSON() 236 const actor = this.Actor.toFormattedJSON()
237 const account = { 237 const videoChannel = {
238 id: this.id, 238 id: this.id,
239 displayName: this.name, 239 displayName: this.name,
240 description: this.description, 240 description: this.description,
241 support: this.support, 241 support: this.support,
242 isLocal: this.Actor.isOwned(), 242 isLocal: this.Actor.isOwned(),
243 createdAt: this.createdAt, 243 createdAt: this.createdAt,
244 updatedAt: this.updatedAt 244 updatedAt: this.updatedAt,
245 ownerAccount: undefined,
246 videos: undefined
247 }
248
249 if (this.Account) {
250 videoChannel.ownerAccount = {
251 id: this.Account.id,
252 uuid: this.Account.Actor.uuid
253 }
245 } 254 }
246 255
247 return Object.assign(actor, account) 256 return Object.assign(actor, videoChannel)
248 } 257 }
249 258
250 toActivityPubObject (): ActivityPubActor { 259 toActivityPubObject (): ActivityPubActor {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 7ababbf23..f23fac2ab 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -430,7 +430,7 @@ export class VideoModel extends Model<VideoModel> {
430 foreignKey: { 430 foreignKey: {
431 allowNull: true 431 allowNull: true
432 }, 432 },
433 onDelete: 'cascade' 433 hooks: true
434 }) 434 })
435 VideoChannel: VideoChannelModel 435 VideoChannel: VideoChannelModel
436 436
@@ -510,10 +510,12 @@ export class VideoModel extends Model<VideoModel> {
510 return undefined 510 return undefined
511 } 511 }
512 512
513 @AfterDestroy 513 @BeforeDestroy
514 static async removeFilesAndSendDelete (instance: VideoModel) { 514 static async removeFilesAndSendDelete (instance: VideoModel) {
515 const tasks: Promise<any>[] = [] 515 const tasks: Promise<any>[] = []
516 516
517 logger.debug('Removing files of video %s.', instance.url)
518
517 tasks.push(instance.removeThumbnail()) 519 tasks.push(instance.removeThumbnail())
518 520
519 if (instance.isOwned()) { 521 if (instance.isOwned()) {
@@ -530,10 +532,13 @@ export class VideoModel extends Model<VideoModel> {
530 }) 532 })
531 } 533 }
532 534
533 return Promise.all(tasks) 535 // Do not wait video deletion because we could be in a transaction
536 Promise.all(tasks)
534 .catch(err => { 537 .catch(err => {
535 logger.error('Some errors when removing files of video %s in after destroy hook.', instance.uuid, { err }) 538 logger.error('Some errors when removing files of video %s in after destroy hook.', instance.uuid, { err })
536 }) 539 })
540
541 return undefined
537 } 542 }
538 543
539 static list () { 544 static list () {