diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-30 11:33:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-30 11:34:34 +0200 |
commit | e04551d796adf69703a41af123207b2624237292 (patch) | |
tree | e5e306785e417d66cb60a1dcff7fe038dd2049cf /server/models/video | |
parent | e20015d744fe9d637bfa6924194f54eecbbd6722 (diff) | |
download | PeerTube-e04551d796adf69703a41af123207b2624237292.tar.gz PeerTube-e04551d796adf69703a41af123207b2624237292.tar.zst PeerTube-e04551d796adf69703a41af123207b2624237292.zip |
Delete actor too when deleting account/video channel
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-channel.ts | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 6567b00d6..33a19f0ff 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -1,15 +1,27 @@ | |||
1 | import { | 1 | import { |
2 | AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table, | 2 | AllowNull, |
3 | UpdatedAt, Default, DataType | 3 | BeforeDestroy, |
4 | BelongsTo, | ||
5 | Column, | ||
6 | CreatedAt, | ||
7 | DataType, | ||
8 | Default, | ||
9 | DefaultScope, | ||
10 | ForeignKey, | ||
11 | HasMany, | ||
12 | Is, | ||
13 | Model, | ||
14 | Scopes, | ||
15 | Table, | ||
16 | UpdatedAt | ||
4 | } from 'sequelize-typescript' | 17 | } from 'sequelize-typescript' |
5 | import { ActivityPubActor } from '../../../shared/models/activitypub' | 18 | import { ActivityPubActor } from '../../../shared/models/activitypub' |
6 | import { VideoChannel } from '../../../shared/models/videos' | 19 | import { VideoChannel } from '../../../shared/models/videos' |
7 | import { | 20 | import { |
8 | isVideoChannelDescriptionValid, isVideoChannelNameValid, | 21 | isVideoChannelDescriptionValid, |
22 | isVideoChannelNameValid, | ||
9 | isVideoChannelSupportValid | 23 | isVideoChannelSupportValid |
10 | } from '../../helpers/custom-validators/video-channels' | 24 | } from '../../helpers/custom-validators/video-channels' |
11 | import { logger } from '../../helpers/logger' | ||
12 | import { sendDeleteActor } from '../../lib/activitypub/send' | ||
13 | import { AccountModel } from '../account/account' | 25 | import { AccountModel } from '../account/account' |
14 | import { ActorModel } from '../activitypub/actor' | 26 | import { ActorModel } from '../activitypub/actor' |
15 | import { getSort, throwIfNotValid } from '../utils' | 27 | import { getSort, throwIfNotValid } from '../utils' |
@@ -139,13 +151,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> { | |||
139 | instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel | 151 | instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel |
140 | } | 152 | } |
141 | 153 | ||
142 | if (instance.Actor.isOwned()) { | 154 | return instance.Actor.destroy({ transaction: options.transaction }) |
143 | logger.debug('Sending delete of actor of video channel %s.', instance.Actor.url) | ||
144 | |||
145 | return sendDeleteActor(instance.Actor, options.transaction) | ||
146 | } | ||
147 | |||
148 | return undefined | ||
149 | } | 155 | } |
150 | 156 | ||
151 | static countByAccount (accountId: number) { | 157 | static countByAccount (accountId: number) { |