From 92bf2f62995bbaa0402cb4657473ad8d5b6fcf8d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 21 Feb 2019 14:06:10 +0100 Subject: Improve channel and account SEO --- server/models/video/video-channel.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'server/models/video/video-channel.ts') diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 5598d80f6..91dd0440c 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -28,7 +28,7 @@ import { AccountModel } from '../account/account' import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' import { buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' -import { CONSTRAINTS_FIELDS } from '../../initializers' +import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' import { ServerModel } from '../server/server' import { DefineIndexesOptions } from 'sequelize' @@ -378,6 +378,14 @@ export class VideoChannelModel extends Model { .findOne(query) } + static loadByNameWithHostAndPopulateAccount (nameWithHost: string) { + const [ name, host ] = nameWithHost.split('@') + + if (!host || host === CONFIG.WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name) + + return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) + } + static loadLocalByNameAndPopulateAccount (name: string) { const query = { include: [ -- cgit v1.2.3