+ @HasMany(() => VideoPlaylistModel, {
+ foreignKey: {
+ allowNull: false
+ },
+ onDelete: 'cascade',
+ hooks: true
+ })
+ VideoPlaylists: VideoPlaylistModel[]
+
+ @HasMany(() => VideoCommentModel, {
+ foreignKey: {
+ allowNull: false
+ },
+ onDelete: 'cascade',
+ hooks: true
+ })
+ VideoComments: VideoCommentModel[]
+
+ @HasMany(() => AccountBlocklistModel, {
+ foreignKey: {
+ name: 'targetAccountId',
+ allowNull: false
+ },
+ as: 'BlockedAccounts',
+ onDelete: 'CASCADE'
+ })
+ BlockedAccounts: AccountBlocklistModel[]
+
+ @BeforeDestroy
+ static async sendDeleteIfOwned (instance: AccountModel, options) {
+ if (!instance.Actor) {
+ instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel
+ }
+
+ await ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction)