X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Faccount%2Faccount.ts;h=5a237d733a0efd06c6fa98ed258c323e7b8c9058;hb=7ad9b9846c44d198a736183fb186c2039f5236b5;hp=d674d8d22de3402f5a230a0289324bbd3c8739c9;hpb=8e0fd45e14993793c64e06682a4a05c29068d398;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/account/account.ts b/server/models/account/account.ts index d674d8d22..5a237d733 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -16,11 +16,9 @@ import { } from 'sequelize-typescript' import { Account } from '../../../shared/models/actors' import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' -import { logger } from '../../helpers/logger' import { sendDeleteActor } from '../../lib/activitypub/send' import { ActorModel } from '../activitypub/actor' import { ApplicationModel } from '../application/application' -import { AvatarModel } from '../avatar/avatar' import { ServerModel } from '../server/server' import { getSort, throwIfNotValid } from '../utils' import { VideoChannelModel } from '../video/video-channel' @@ -30,18 +28,8 @@ import { UserModel } from './user' @DefaultScope({ include: [ { - model: () => ActorModel, - required: true, - include: [ - { - model: () => ServerModel, - required: false - }, - { - model: () => AvatarModel, - required: false - } - ] + model: () => ActorModel, // Default scope includes avatar and server + required: true } ] }) @@ -145,8 +133,8 @@ export class AccountModel extends Model { return undefined } - static load (id: number) { - return AccountModel.findById(id) + static load (id: number, transaction?: Sequelize.Transaction) { + return AccountModel.findById(id, { transaction }) } static loadByUUID (uuid: string) { @@ -195,7 +183,7 @@ export class AccountModel extends Model { return AccountModel.findOne(query) } - static loadLocalByNameAndHost (name: string, host: string) { + static loadByNameAndHost (name: string, host: string) { const query = { include: [ { @@ -260,7 +248,8 @@ export class AccountModel extends Model { displayName: this.getDisplayName(), description: this.description, createdAt: this.createdAt, - updatedAt: this.updatedAt + updatedAt: this.updatedAt, + userId: this.userId ? this.userId : undefined } return Object.assign(actor, account)