X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fserver%2Fserver.ts;h=a5e05f460fffcfe90c8026321f6df023c513b121;hb=5e47f6ab984a7d00782e4c7030afffa1ba480add;hp=25d9924fb33e7f91b8fc1f8bb6be01fa002ea8cb;hpb=96d52038788dda2f479362ce8e980f895369eec7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/server/server.ts b/server/models/server/server.ts index 25d9924fb..a5e05f460 100644 --- a/server/models/server/server.ts +++ b/server/models/server/server.ts @@ -1,9 +1,10 @@ +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' +import { buildSQLAttributes, throwIfNotValid } from '../shared' import { ServerBlocklistModel } from './server-blocklist' @Table({ @@ -49,13 +50,26 @@ export class ServerModel extends Model>> { }, onDelete: 'CASCADE' }) - BlockedByAccounts: ServerBlocklistModel[] + BlockedBy: ServerBlocklistModel[] - static load (id: number): Promise { + // --------------------------------------------------------------------------- + + static getSQLAttributes (tableName: string, aliasPrefix = '') { + return buildSQLAttributes({ + model: this, + tableName, + aliasPrefix + }) + } + + // --------------------------------------------------------------------------- + + static load (id: number, transaction?: Transaction): Promise { const query = { where: { id - } + }, + transaction } return ServerModel.findOne(query) @@ -79,7 +93,7 @@ export class ServerModel extends Model>> { } isBlocked () { - return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0 + return this.BlockedBy && this.BlockedBy.length !== 0 } toFormattedJSON (this: MServerFormattable) {