+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/core-utils'
import { isHostValid } from '../../helpers/custom-validators/servers'
-import { ActorModel } from '../activitypub/actor'
+import { ActorModel } from '../actor/actor'
import { throwIfNotValid } from '../utils'
import { ServerBlocklistModel } from './server-blocklist'
-import * as Bluebird from 'bluebird'
-import { MServer, MServerFormattable } from '@server/typings/models/server'
@Table({
tableName: 'server',
}
]
})
-export class ServerModel extends Model<ServerModel> {
+export class ServerModel extends Model<Partial<AttributesOnly<ServerModel>>> {
@AllowNull(false)
@Is('Host', value => throwIfNotValid(value, isHostValid, 'valid host'))
})
BlockedByAccounts: ServerBlocklistModel[]
- static load (id: number): Bluebird<MServer> {
+ static load (id: number, transaction?: Transaction): Promise<MServer> {
const query = {
where: {
id
- }
+ },
+ transaction
}
return ServerModel.findOne(query)
}
- static loadByHost (host: string): Bluebird<MServer> {
+ static loadByHost (host: string): Promise<MServer> {
const query = {
where: {
host