+import { Transaction } from 'sequelize'
import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { MServer, MServerFormattable } from '@server/types/models/server'
+import { AttributesOnly } from '@shared/typescript-utils'
import { isHostValid } from '../../helpers/custom-validators/servers'
import { ActorModel } from '../actor/actor'
import { throwIfNotValid } from '../utils'
}
]
})
-export class ServerModel extends Model {
+export class ServerModel extends Model<Partial<AttributesOnly<ServerModel>>> {
@AllowNull(false)
@Is('Host', value => throwIfNotValid(value, isHostValid, 'valid host'))
},
onDelete: 'CASCADE'
})
- BlockedByAccounts: ServerBlocklistModel[]
+ BlockedBy: ServerBlocklistModel[]
- static load (id: number): Promise<MServer> {
+ static load (id: number, transaction?: Transaction): Promise<MServer> {
const query = {
where: {
id
- }
+ },
+ transaction
}
return ServerModel.findOne(query)
}
isBlocked () {
- return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0
+ return this.BlockedBy && this.BlockedBy.length !== 0
}
toFormattedJSON (this: MServerFormattable) {