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, 17 insertions, 8 deletions
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 267032e2a..f231dba74 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -3,6 +3,7 @@ import { extname } from 'path'
3import * as Sequelize from 'sequelize' 3import * as Sequelize from 'sequelize'
4import { 4import {
5 AllowNull, 5 AllowNull,
6 BeforeDestroy,
6 BelongsTo, 7 BelongsTo,
7 Column, 8 Column,
8 CreatedAt, 9 CreatedAt,
@@ -37,6 +38,8 @@ import { ServerModel } from '../server/server'
37import { throwIfNotValid } from '../utils' 38import { throwIfNotValid } from '../utils'
38import { VideoChannelModel } from '../video/video-channel' 39import { VideoChannelModel } from '../video/video-channel'
39import { ActorFollowModel } from './actor-follow' 40import { ActorFollowModel } from './actor-follow'
41import { logger } from '../../helpers/logger'
42import { sendDeleteActor } from '../../lib/activitypub/send'
40 43
41enum ScopeNames { 44enum ScopeNames {
42 FULL = 'FULL' 45 FULL = 'FULL'
@@ -224,22 +227,28 @@ export class ActorModel extends Model<ActorModel> {
224 227
225 @HasOne(() => AccountModel, { 228 @HasOne(() => AccountModel, {
226 foreignKey: { 229 foreignKey: {
227 allowNull: true 230 allowNull: false
228 }, 231 }
229 onDelete: 'cascade',
230 hooks: true
231 }) 232 })
232 Account: AccountModel 233 Account: AccountModel
233 234
234 @HasOne(() => VideoChannelModel, { 235 @HasOne(() => VideoChannelModel, {
235 foreignKey: { 236 foreignKey: {
236 allowNull: true 237 allowNull: false
237 }, 238 }
238 onDelete: 'cascade',
239 hooks: true
240 }) 239 })
241 VideoChannel: VideoChannelModel 240 VideoChannel: VideoChannelModel
242 241
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
243 static load (id: number) { 252 static load (id: number) {
244 return ActorModel.unscoped().findById(id) 253 return ActorModel.unscoped().findById(id)
245 } 254 }