From c5a893d5363ce1fd681751cf48977086a35d5724 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Jul 2018 13:39:20 +0200 Subject: Revert "Delete actor too when deleting account/video channel" This reverts commit e04551d796adf69703a41af123207b2624237292. See https://github.com/Chocobozzz/PeerTube/issues/870#issuecomment-408814420 --- server/models/activitypub/actor.ts | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'server/models/activitypub/actor.ts') diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index f231dba74..267032e2a 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -3,7 +3,6 @@ import { extname } from 'path' import * as Sequelize from 'sequelize' import { AllowNull, - BeforeDestroy, BelongsTo, Column, CreatedAt, @@ -38,8 +37,6 @@ import { ServerModel } from '../server/server' import { throwIfNotValid } from '../utils' import { VideoChannelModel } from '../video/video-channel' import { ActorFollowModel } from './actor-follow' -import { logger } from '../../helpers/logger' -import { sendDeleteActor } from '../../lib/activitypub/send' enum ScopeNames { FULL = 'FULL' @@ -227,28 +224,22 @@ export class ActorModel extends Model { @HasOne(() => AccountModel, { foreignKey: { - allowNull: false - } + allowNull: true + }, + onDelete: 'cascade', + hooks: true }) Account: AccountModel @HasOne(() => VideoChannelModel, { foreignKey: { - allowNull: false - } + allowNull: true + }, + onDelete: 'cascade', + hooks: true }) VideoChannel: VideoChannelModel - @BeforeDestroy - static async sendDeleteIfOwned (instance: ActorModel, options) { - if (instance.isOwned()) { - logger.debug('Sending delete of actor %s.', instance.url) - return sendDeleteActor(instance, options.transaction) - } - - return undefined - } - static load (id: number) { return ActorModel.unscoped().findById(id) } -- cgit v1.2.3