diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index a0081f259..ad649837a 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 | |||
32 | import { AccountBlocklistModel } from './account-blocklist' | 32 | import { AccountBlocklistModel } from './account-blocklist' |
33 | import { ServerBlocklistModel } from '../server/server-blocklist' | 33 | import { ServerBlocklistModel } from '../server/server-blocklist' |
34 | import { ActorFollowModel } from '../activitypub/actor-follow' | 34 | import { ActorFollowModel } from '../activitypub/actor-follow' |
35 | import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable } from '../../typings/models' | 35 | import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable, MAccount } from '../../typings/models' |
36 | import * as Bluebird from 'bluebird' | 36 | import * as Bluebird from 'bluebird' |
37 | import { ModelCache } from '@server/models/model-cache' | 37 | import { ModelCache } from '@server/models/model-cache' |
38 | import { VideoModel } from '../video/video' | ||
38 | 39 | ||
39 | export enum ScopeNames { | 40 | export enum ScopeNames { |
40 | SUMMARY = 'SUMMARY' | 41 | SUMMARY = 'SUMMARY' |
@@ -343,6 +344,29 @@ export class AccountModel extends Model<AccountModel> { | |||
343 | }) | 344 | }) |
344 | } | 345 | } |
345 | 346 | ||
347 | static loadAccountIdFromVideo (videoId: number): Bluebird<MAccount> { | ||
348 | const query = { | ||
349 | include: [ | ||
350 | { | ||
351 | attributes: [ 'id', 'accountId' ], | ||
352 | model: VideoChannelModel.unscoped(), | ||
353 | required: true, | ||
354 | include: [ | ||
355 | { | ||
356 | attributes: [ 'id', 'channelId' ], | ||
357 | model: VideoModel.unscoped(), | ||
358 | where: { | ||
359 | id: videoId | ||
360 | } | ||
361 | } | ||
362 | ] | ||
363 | } | ||
364 | ] | ||
365 | } | ||
366 | |||
367 | return AccountModel.findOne(query) | ||
368 | } | ||
369 | |||
346 | static listLocalsForSitemap (sort: string): Bluebird<MAccountActor[]> { | 370 | static listLocalsForSitemap (sort: string): Bluebird<MAccountActor[]> { |
347 | const query = { | 371 | const query = { |
348 | attributes: [ ], | 372 | attributes: [ ], |