diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-18 10:53:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-18 15:42:20 +0100 |
commit | f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad (patch) | |
tree | 6d90c0de5dd3ad506e738d447e4f396951ed5624 /server/models/video/video-channel.ts | |
parent | 1174a8479ab9ee47b3305d668fe757435057a298 (diff) | |
download | PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.gz PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.zst PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.zip |
Don't show videos of remote instance after unfollow
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r-- | server/models/video/video-channel.ts | 29 |
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 @@ | |||
1 | import { | 1 | import { |
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' |
16 | import { ActivityPubActor } from '../../../shared/models/activitypub' | 5 | import { ActivityPubActor } from '../../../shared/models/activitypub' |
17 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' | 6 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' |
7 | import { logger } from '../../helpers/logger' | ||
18 | import { sendDeleteActor } from '../../lib/activitypub/send' | 8 | import { sendDeleteActor } from '../../lib/activitypub/send' |
19 | import { AccountModel } from '../account/account' | 9 | import { AccountModel } from '../account/account' |
20 | import { ActorModel } from '../activitypub/actor' | 10 | import { 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 |