aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/activitypub/actor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/activitypub/actor.ts')
-rw-r--r--server/models/activitypub/actor.ts25
1 files changed, 8 insertions, 17 deletions
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'
3import * as Sequelize from 'sequelize' 3import * as Sequelize from 'sequelize'
4import { 4import {
5 AllowNull, 5 AllowNull,
6 BeforeDestroy,
7 BelongsTo, 6 BelongsTo,
8 Column, 7 Column,
9 CreatedAt, 8 CreatedAt,
@@ -38,8 +37,6 @@ import { ServerModel } from '../server/server'
38import { throwIfNotValid } from '../utils' 37import { throwIfNotValid } from '../utils'
39import { VideoChannelModel } from '../video/video-channel' 38import { VideoChannelModel } from '../video/video-channel'
40import { ActorFollowModel } from './actor-follow' 39import { ActorFollowModel } from './actor-follow'
41import { logger } from '../../helpers/logger'
42import { sendDeleteActor } from '../../lib/activitypub/send'
43 40
44enum ScopeNames { 41enum ScopeNames {
45 FULL = 'FULL' 42 FULL = 'FULL'
@@ -227,28 +224,22 @@ export class ActorModel extends Model<ActorModel> {
227 224
228 @HasOne(() => AccountModel, { 225 @HasOne(() => AccountModel, {
229 foreignKey: { 226 foreignKey: {
230 allowNull: false 227 allowNull: true
231 } 228 },
229 onDelete: 'cascade',
230 hooks: true
232 }) 231 })
233 Account: AccountModel 232 Account: AccountModel
234 233
235 @HasOne(() => VideoChannelModel, { 234 @HasOne(() => VideoChannelModel, {
236 foreignKey: { 235 foreignKey: {
237 allowNull: false 236 allowNull: true
238 } 237 },
238 onDelete: 'cascade',
239 hooks: true
239 }) 240 })
240 VideoChannel: VideoChannelModel 241 VideoChannel: VideoChannelModel
241 242
242 @BeforeDestroy
243 static async sendDeleteIfOwned (instance: ActorModel, options) {
244 if (instance.isOwned()) {
245 logger.debug('Sending delete of actor %s.', instance.url)
246 return sendDeleteActor(instance, options.transaction)
247 }
248
249 return undefined
250 }
251
252 static load (id: number) { 243 static load (id: number) {
253 return ActorModel.unscoped().findById(id) 244 return ActorModel.unscoped().findById(id)
254 } 245 }