diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-08 10:53:41 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-08 11:15:11 +0100 |
commit | a59f210ff3a4cc87dd19aeaaf0f43f63a8310791 (patch) | |
tree | 82ffcc8f6dcee07ad0776a5d3937f8953a958bf8 /server/models/account | |
parent | e5024f5181b2e8ec23a58a821671000041b5bf2b (diff) | |
download | PeerTube-a59f210ff3a4cc87dd19aeaaf0f43f63a8310791.tar.gz PeerTube-a59f210ff3a4cc87dd19aeaaf0f43f63a8310791.tar.zst PeerTube-a59f210ff3a4cc87dd19aeaaf0f43f63a8310791.zip |
Refactor a little bit client canonical URL
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account.ts | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 1162643be..8c244d432 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize' | ||
1 | import { | 3 | import { |
2 | AllowNull, | 4 | AllowNull, |
3 | BeforeDestroy, | 5 | BeforeDestroy, |
@@ -15,27 +17,33 @@ import { | |||
15 | Table, | 17 | Table, |
16 | UpdatedAt | 18 | UpdatedAt |
17 | } from 'sequelize-typescript' | 19 | } from 'sequelize-typescript' |
20 | import { ModelCache } from '@server/models/model-cache' | ||
18 | import { Account, AccountSummary } from '../../../shared/models/actors' | 21 | import { Account, AccountSummary } from '../../../shared/models/actors' |
19 | import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' | 22 | import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' |
23 | import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' | ||
20 | import { sendDeleteActor } from '../../lib/activitypub/send' | 24 | import { sendDeleteActor } from '../../lib/activitypub/send' |
25 | import { | ||
26 | MAccount, | ||
27 | MAccountActor, | ||
28 | MAccountAP, | ||
29 | MAccountDefault, | ||
30 | MAccountFormattable, | ||
31 | MAccountSummaryFormattable, | ||
32 | MChannelActor | ||
33 | } from '../../types/models' | ||
21 | import { ActorModel } from '../activitypub/actor' | 34 | import { ActorModel } from '../activitypub/actor' |
35 | import { ActorFollowModel } from '../activitypub/actor-follow' | ||
22 | import { ApplicationModel } from '../application/application' | 36 | import { ApplicationModel } from '../application/application' |
37 | import { AvatarModel } from '../avatar/avatar' | ||
23 | import { ServerModel } from '../server/server' | 38 | import { ServerModel } from '../server/server' |
39 | import { ServerBlocklistModel } from '../server/server-blocklist' | ||
24 | import { getSort, throwIfNotValid } from '../utils' | 40 | import { getSort, throwIfNotValid } from '../utils' |
41 | import { VideoModel } from '../video/video' | ||
25 | import { VideoChannelModel } from '../video/video-channel' | 42 | import { VideoChannelModel } from '../video/video-channel' |
26 | import { VideoCommentModel } from '../video/video-comment' | 43 | import { VideoCommentModel } from '../video/video-comment' |
27 | import { UserModel } from './user' | ||
28 | import { AvatarModel } from '../avatar/avatar' | ||
29 | import { VideoPlaylistModel } from '../video/video-playlist' | 44 | import { VideoPlaylistModel } from '../video/video-playlist' |
30 | import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' | ||
31 | import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize' | ||
32 | import { AccountBlocklistModel } from './account-blocklist' | 45 | import { AccountBlocklistModel } from './account-blocklist' |
33 | import { ServerBlocklistModel } from '../server/server-blocklist' | 46 | import { UserModel } from './user' |
34 | import { ActorFollowModel } from '../activitypub/actor-follow' | ||
35 | import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable, MAccount } from '../../types/models' | ||
36 | import * as Bluebird from 'bluebird' | ||
37 | import { ModelCache } from '@server/models/model-cache' | ||
38 | import { VideoModel } from '../video/video' | ||
39 | 47 | ||
40 | export enum ScopeNames { | 48 | export enum ScopeNames { |
41 | SUMMARY = 'SUMMARY' | 49 | SUMMARY = 'SUMMARY' |
@@ -441,6 +449,10 @@ export class AccountModel extends Model<AccountModel> { | |||
441 | return this.name | 449 | return this.name |
442 | } | 450 | } |
443 | 451 | ||
452 | getLocalUrl (this: MAccountActor | MChannelActor) { | ||
453 | return WEBSERVER.URL + `/accounts/` + this.Actor.preferredUsername | ||
454 | } | ||
455 | |||
444 | isBlocked () { | 456 | isBlocked () { |
445 | return this.BlockedAccounts && this.BlockedAccounts.length !== 0 | 457 | return this.BlockedAccounts && this.BlockedAccounts.length !== 0 |
446 | } | 458 | } |