aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts29
1 files changed, 13 insertions, 16 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index e2cbf0422..7c161c864 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -1,20 +1,10 @@
1import { 1import {
2 AfterDestroy, 2 AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table,
3 AllowNull,
4 BelongsTo,
5 Column,
6 CreatedAt,
7 DefaultScope,
8 ForeignKey,
9 HasMany,
10 Is,
11 Model,
12 Scopes,
13 Table,
14 UpdatedAt 3 UpdatedAt
15} from 'sequelize-typescript' 4} from 'sequelize-typescript'
16import { ActivityPubActor } from '../../../shared/models/activitypub' 5import { ActivityPubActor } from '../../../shared/models/activitypub'
17import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' 6import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels'
7import { logger } from '../../helpers/logger'
18import { sendDeleteActor } from '../../lib/activitypub/send' 8import { sendDeleteActor } from '../../lib/activitypub/send'
19import { AccountModel } from '../account/account' 9import { AccountModel } from '../account/account'
20import { ActorModel } from '../activitypub/actor' 10import { ActorModel } from '../activitypub/actor'
@@ -116,14 +106,21 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
116 name: 'channelId', 106 name: 'channelId',
117 allowNull: false 107 allowNull: false
118 }, 108 },
119 onDelete: 'CASCADE' 109 onDelete: 'CASCADE',
110 hooks: true
120 }) 111 })
121 Videos: VideoModel[] 112 Videos: VideoModel[]
122 113
123 @AfterDestroy 114 @BeforeDestroy
124 static sendDeleteIfOwned (instance: VideoChannelModel) { 115 static async sendDeleteIfOwned (instance: VideoChannelModel, options) {
116 if (!instance.Actor) {
117 instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel
118 }
119
125 if (instance.Actor.isOwned()) { 120 if (instance.Actor.isOwned()) {
126 return sendDeleteActor(instance.Actor, undefined) 121 logger.debug('Sending delete of actor of video channel %s.', instance.Actor.url)
122
123 return sendDeleteActor(instance.Actor, options.transaction)
127 } 124 }
128 125
129 return undefined 126 return undefined