]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/server/server.ts
Move typescript utils in its own directory
[github/Chocobozzz/PeerTube.git] / server / models / server / server.ts
index 25d9924fb33e7f91b8fc1f8bb6be01fa002ea8cb..ef42de09063b0f5ed7bf9d511e7d7d01c4fe65cf 100644 (file)
@@ -1,6 +1,7 @@
+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 { AttributesOnly } from '@shared/typescript-utils'
 import { isHostValid } from '../../helpers/custom-validators/servers'
 import { ActorModel } from '../actor/actor'
 import { throwIfNotValid } from '../utils'
@@ -49,13 +50,14 @@ export class ServerModel extends Model<Partial<AttributesOnly<ServerModel>>> {
     },
     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)
@@ -79,7 +81,7 @@ export class ServerModel extends Model<Partial<AttributesOnly<ServerModel>>> {
   }
 
   isBlocked () {
-    return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0
+    return this.BlockedBy && this.BlockedBy.length !== 0
   }
 
   toFormattedJSON (this: MServerFormattable) {