X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Faccount%2Faccount.ts;h=396959352c3792b9bae35f80f9e68e475e9f1cf7;hb=HEAD;hp=dc989417bf2ab4c9aea8020e3127584e645c90d4;hpb=8ca52bcc2c37d457e8b19a237c66b8dd1c00b6b9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/account/account.ts b/server/models/account/account.ts index dc989417b..396959352 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -28,8 +28,9 @@ import { MAccountAP, MAccountDefault, MAccountFormattable, + MAccountHost, MAccountSummaryFormattable, - MChannelActor + MChannelHost } from '../../types/models' import { ActorModel } from '../actor/actor' import { ActorFollowModel } from '../actor/actor-follow' @@ -37,8 +38,8 @@ import { ActorImageModel } from '../actor/actor-image' import { ApplicationModel } from '../application/application' import { ServerModel } from '../server/server' import { ServerBlocklistModel } from '../server/server-blocklist' -import { UserModel } from '../user/user' import { buildSQLAttributes, getSort, throwIfNotValid } from '../shared' +import { UserModel } from '../user/user' import { VideoModel } from '../video/video' import { VideoChannelModel } from '../video/video-channel' import { VideoCommentModel } from '../video/video-comment' @@ -296,9 +297,7 @@ export class AccountModel extends Model>> { { model: ActorModel, required: true, - where: { - preferredUsername: name - } + where: ActorModel.wherePreferredUsername(name) } ] } @@ -321,9 +320,7 @@ export class AccountModel extends Model>> { { model: ActorModel, required: true, - where: { - preferredUsername: name - }, + where: ActorModel.wherePreferredUsername(name), include: [ { model: ServerModel, @@ -414,10 +411,6 @@ export class AccountModel extends Model>> { .findAll(query) } - getClientUrl () { - return WEBSERVER.URL + '/accounts/' + this.Actor.getIdentifier() - } - toFormattedJSON (this: MAccountFormattable): Account { return { ...this.Actor.toFormattedJSON(), @@ -447,8 +440,8 @@ export class AccountModel extends Model>> { } } - toActivityPubObject (this: MAccountAP) { - const obj = this.Actor.toActivityPubObject(this.name) + async toActivityPubObject (this: MAccountAP) { + const obj = await this.Actor.toActivityPubObject(this.name) return Object.assign(obj, { summary: this.description @@ -467,8 +460,9 @@ export class AccountModel extends Model>> { return this.name } - getLocalUrl (this: MAccountActor | MChannelActor) { - return WEBSERVER.URL + `/accounts/` + this.Actor.preferredUsername + // Avoid error when running this method on MAccount... | MChannel... + getClientUrl (this: MAccountHost | MChannelHost) { + return WEBSERVER.URL + '/a/' + this.Actor.getIdentifier() } isBlocked () {