X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fserver%2Fserver.ts;h=8b07115f1f810a43c0403f7ef7b75b3702ff64a0;hb=a30a136c9896c656cab98d2c92cde32c534dc098;hp=1d211f1e06b2619bd6a4142c31bfd0852d3b0792;hpb=bfbd912886eba17b4aa9a40dcef2fddc685d85bf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 1d211f1e0..8b07115f1 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts @@ -2,8 +2,9 @@ import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, Updat import { isHostValid } from '../../helpers/custom-validators/servers' import { ActorModel } from '../activitypub/actor' import { throwIfNotValid } from '../utils' -import { AccountBlocklistModel } from '../account/account-blocklist' import { ServerBlocklistModel } from './server-blocklist' +import * as Bluebird from 'bluebird' +import { MServer, MServerFormattable } from '@server/typings/models/server' @Table({ tableName: 'server', @@ -50,7 +51,17 @@ export class ServerModel extends Model { }) BlockedByAccounts: ServerBlocklistModel[] - static loadByHost (host: string) { + static load (id: number): Bluebird { + const query = { + where: { + id + } + } + + return ServerModel.findOne(query) + } + + static loadByHost (host: string): Bluebird { const query = { where: { host @@ -64,7 +75,7 @@ export class ServerModel extends Model { return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0 } - toFormattedJSON () { + toFormattedJSON (this: MServerFormattable) { return { host: this.host }