-import { AllowNull, Column, CreatedAt, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
+import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
import { isHostValid } from '../../helpers/custom-validators/servers'
import { ActorModel } from '../activitypub/actor'
import { throwIfNotValid } from '../utils'
@Column
host: string
+ @AllowNull(false)
+ @Default(false)
+ @Column
+ redundancyAllowed: boolean
+
@CreatedAt
createdAt: Date
hooks: true
})
Actors: ActorModel[]
+
+ static loadByHost (host: string) {
+ const query = {
+ where: {
+ host
+ }
+ }
+
+ return ServerModel.findOne(query)
+ }
+
+ toFormattedJSON () {
+ return {
+ host: this.host
+ }
+ }
}