X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Faccount%2Faccount.ts;h=466d6258e1cdafce825adab256c83c38bb92aa6f;hb=d95d15598847c7f020aa056e7e6e0c02d2bbf732;hp=a0081f25995cfefc34b4d4cc5d442e925d428be6;hpb=4c1def5fd8e9f483238eb38e221f555e2e6bbf07;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/account/account.ts b/server/models/account/account.ts index a0081f259..466d6258e 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -32,9 +32,10 @@ import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequ import { AccountBlocklistModel } from './account-blocklist' import { ServerBlocklistModel } from '../server/server-blocklist' import { ActorFollowModel } from '../activitypub/actor-follow' -import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable } from '../../typings/models' +import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable, MAccount } from '../../types/models' import * as Bluebird from 'bluebird' import { ModelCache } from '@server/models/model-cache' +import { VideoModel } from '../video/video' export enum ScopeNames { SUMMARY = 'SUMMARY' @@ -343,6 +344,29 @@ export class AccountModel extends Model { }) } + static loadAccountIdFromVideo (videoId: number): Bluebird { + const query = { + include: [ + { + attributes: [ 'id', 'accountId' ], + model: VideoChannelModel.unscoped(), + required: true, + include: [ + { + attributes: [ 'id', 'channelId' ], + model: VideoModel.unscoped(), + where: { + id: videoId + } + } + ] + } + ] + } + + return AccountModel.findOne(query) + } + static listLocalsForSitemap (sort: string): Bluebird { const query = { attributes: [ ], @@ -364,6 +388,10 @@ export class AccountModel extends Model { .findAll(query) } + getClientUrl () { + return WEBSERVER.URL + '/accounts/' + this.Actor.getIdentifier() + } + toFormattedJSON (this: MAccountFormattable): Account { const actor = this.Actor.toFormattedJSON() const account = {