} from 'sequelize-typescript'
import { Account } from '../../../shared/models/actors'
import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts'
-import { logger } from '../../helpers/logger'
-import { sendDeleteActor } from '../../lib/activitypub/send'
import { ActorModel } from '../activitypub/actor'
import { ApplicationModel } from '../application/application'
import { AvatarModel } from '../avatar/avatar'
instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel
}
- if (instance.isOwned()) {
- logger.debug('Sending delete of actor of account %s.', instance.Actor.url)
- return sendDeleteActor(instance.Actor, options.transaction)
- }
-
- return undefined
+ return instance.Actor.destroy({ transaction: options.transaction })
}
static load (id: number) {
}
return AccountModel.findAndCountAll(query)
- .then(({ rows, count }) => {
- return {
- data: rows,
- total: count
- }
- })
+ .then(({ rows, count }) => {
+ return {
+ data: rows,
+ total: count
+ }
+ })
}
toFormattedJSON (): Account {
import * as Sequelize from 'sequelize'
import {
AllowNull,
+ BeforeDestroy,
BelongsTo,
Column,
CreatedAt,
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'
@HasOne(() => AccountModel, {
foreignKey: {
- allowNull: true
- },
- onDelete: 'cascade',
- hooks: true
+ allowNull: false
+ }
})
Account: AccountModel
@HasOne(() => VideoChannelModel, {
foreignKey: {
- allowNull: true
- },
- onDelete: 'cascade',
- hooks: true
+ allowNull: false
+ }
})
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)
}
import {
- AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table,
- UpdatedAt, Default, DataType
+ AllowNull,
+ BeforeDestroy,
+ BelongsTo,
+ Column,
+ CreatedAt,
+ DataType,
+ Default,
+ DefaultScope,
+ ForeignKey,
+ HasMany,
+ Is,
+ Model,
+ Scopes,
+ Table,
+ UpdatedAt
} from 'sequelize-typescript'
import { ActivityPubActor } from '../../../shared/models/activitypub'
import { VideoChannel } from '../../../shared/models/videos'
import {
- isVideoChannelDescriptionValid, isVideoChannelNameValid,
+ isVideoChannelDescriptionValid,
+ isVideoChannelNameValid,
isVideoChannelSupportValid
} from '../../helpers/custom-validators/video-channels'
-import { logger } from '../../helpers/logger'
-import { sendDeleteActor } from '../../lib/activitypub/send'
import { AccountModel } from '../account/account'
import { ActorModel } from '../activitypub/actor'
import { getSort, throwIfNotValid } from '../utils'
instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel
}
- if (instance.Actor.isOwned()) {
- logger.debug('Sending delete of actor of video channel %s.', instance.Actor.url)
-
- return sendDeleteActor(instance.Actor, options.transaction)
- }
-
- return undefined
+ return instance.Actor.destroy({ transaction: options.transaction })
}
static countByAccount (accountId: number) {