From a59f210ff3a4cc87dd19aeaaf0f43f63a8310791 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 8 Dec 2020 10:53:41 +0100 Subject: Refactor a little bit client canonical URL --- server/models/account/account.ts | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'server/models/account') 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 @@ +import * as Bluebird from 'bluebird' +import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize' import { AllowNull, BeforeDestroy, @@ -15,27 +17,33 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { ModelCache } from '@server/models/model-cache' import { Account, AccountSummary } from '../../../shared/models/actors' import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' +import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' import { sendDeleteActor } from '../../lib/activitypub/send' +import { + MAccount, + MAccountActor, + MAccountAP, + MAccountDefault, + MAccountFormattable, + MAccountSummaryFormattable, + MChannelActor +} from '../../types/models' import { ActorModel } from '../activitypub/actor' +import { ActorFollowModel } from '../activitypub/actor-follow' import { ApplicationModel } from '../application/application' +import { AvatarModel } from '../avatar/avatar' import { ServerModel } from '../server/server' +import { ServerBlocklistModel } from '../server/server-blocklist' import { getSort, throwIfNotValid } from '../utils' +import { VideoModel } from '../video/video' import { VideoChannelModel } from '../video/video-channel' import { VideoCommentModel } from '../video/video-comment' -import { UserModel } from './user' -import { AvatarModel } from '../avatar/avatar' import { VideoPlaylistModel } from '../video/video-playlist' -import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' -import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize' import { AccountBlocklistModel } from './account-blocklist' -import { ServerBlocklistModel } from '../server/server-blocklist' -import { ActorFollowModel } from '../activitypub/actor-follow' -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' +import { UserModel } from './user' export enum ScopeNames { SUMMARY = 'SUMMARY' @@ -441,6 +449,10 @@ export class AccountModel extends Model { return this.name } + getLocalUrl (this: MAccountActor | MChannelActor) { + return WEBSERVER.URL + `/accounts/` + this.Actor.preferredUsername + } + isBlocked () { return this.BlockedAccounts && this.BlockedAccounts.length !== 0 } -- cgit v1.2.3