aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-12-08 10:53:41 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-12-08 11:15:11 +0100
commita59f210ff3a4cc87dd19aeaaf0f43f63a8310791 (patch)
tree82ffcc8f6dcee07ad0776a5d3937f8953a958bf8 /server/models/account
parente5024f5181b2e8ec23a58a821671000041b5bf2b (diff)
downloadPeerTube-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.ts32
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 @@
1import * as Bluebird from 'bluebird'
2import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize'
1import { 3import {
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'
20import { ModelCache } from '@server/models/model-cache'
18import { Account, AccountSummary } from '../../../shared/models/actors' 21import { Account, AccountSummary } from '../../../shared/models/actors'
19import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' 22import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts'
23import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants'
20import { sendDeleteActor } from '../../lib/activitypub/send' 24import { sendDeleteActor } from '../../lib/activitypub/send'
25import {
26 MAccount,
27 MAccountActor,
28 MAccountAP,
29 MAccountDefault,
30 MAccountFormattable,
31 MAccountSummaryFormattable,
32 MChannelActor
33} from '../../types/models'
21import { ActorModel } from '../activitypub/actor' 34import { ActorModel } from '../activitypub/actor'
35import { ActorFollowModel } from '../activitypub/actor-follow'
22import { ApplicationModel } from '../application/application' 36import { ApplicationModel } from '../application/application'
37import { AvatarModel } from '../avatar/avatar'
23import { ServerModel } from '../server/server' 38import { ServerModel } from '../server/server'
39import { ServerBlocklistModel } from '../server/server-blocklist'
24import { getSort, throwIfNotValid } from '../utils' 40import { getSort, throwIfNotValid } from '../utils'
41import { VideoModel } from '../video/video'
25import { VideoChannelModel } from '../video/video-channel' 42import { VideoChannelModel } from '../video/video-channel'
26import { VideoCommentModel } from '../video/video-comment' 43import { VideoCommentModel } from '../video/video-comment'
27import { UserModel } from './user'
28import { AvatarModel } from '../avatar/avatar'
29import { VideoPlaylistModel } from '../video/video-playlist' 44import { VideoPlaylistModel } from '../video/video-playlist'
30import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants'
31import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize'
32import { AccountBlocklistModel } from './account-blocklist' 45import { AccountBlocklistModel } from './account-blocklist'
33import { ServerBlocklistModel } from '../server/server-blocklist' 46import { UserModel } from './user'
34import { ActorFollowModel } from '../activitypub/actor-follow'
35import { MAccountActor, MAccountAP, MAccountDefault, MAccountFormattable, MAccountSummaryFormattable, MAccount } from '../../types/models'
36import * as Bluebird from 'bluebird'
37import { ModelCache } from '@server/models/model-cache'
38import { VideoModel } from '../video/video'
39 47
40export enum ScopeNames { 48export 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 }