]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/server/server.ts
Merge branch 'master' into develop
[github/Chocobozzz/PeerTube.git] / server / models / server / server.ts
index 1d211f1e06b2619bd6a4142c31bfd0852d3b0792..8b07115f1f810a43c0403f7ef7b75b3702ff64a0 100644 (file)
@@ -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<ServerModel> {
   })
   BlockedByAccounts: ServerBlocklistModel[]
 
-  static loadByHost (host: string) {
+  static load (id: number): Bluebird<MServer> {
+    const query = {
+      where: {
+        id
+      }
+    }
+
+    return ServerModel.findOne(query)
+  }
+
+  static loadByHost (host: string): Bluebird<MServer> {
     const query = {
       where: {
         host
@@ -64,7 +75,7 @@ export class ServerModel extends Model<ServerModel> {
     return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0
   }
 
-  toFormattedJSON () {
+  toFormattedJSON (this: MServerFormattable) {
     return {
       host: this.host
     }