diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-21 14:06:10 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-21 14:06:10 +0100 |
commit | 92bf2f62995bbaa0402cb4657473ad8d5b6fcf8d (patch) | |
tree | 7f3f34b1503fd21db7f0b913c3b908f004015011 /server/helpers/custom-validators | |
parent | 84c7cde6e81426a42e7aa29187b473bc89f1c8f6 (diff) | |
download | PeerTube-92bf2f62995bbaa0402cb4657473ad8d5b6fcf8d.tar.gz PeerTube-92bf2f62995bbaa0402cb4657473ad8d5b6fcf8d.tar.zst PeerTube-92bf2f62995bbaa0402cb4657473ad8d5b6fcf8d.zip |
Improve channel and account SEO
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 8 | ||||
-rw-r--r-- | server/helpers/custom-validators/video-channels.ts | 6 |
2 files changed, 2 insertions, 12 deletions
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index 191de1496..aad04fe93 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -38,13 +38,7 @@ function isLocalAccountNameExist (name: string, res: Response, sendNotFound = tr | |||
38 | } | 38 | } |
39 | 39 | ||
40 | function isAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) { | 40 | function isAccountNameWithHostExist (nameWithDomain: string, res: Response, sendNotFound = true) { |
41 | const [ accountName, host ] = nameWithDomain.split('@') | 41 | return isAccountExist(AccountModel.loadByNameWithHost(nameWithDomain), res, sendNotFound) |
42 | |||
43 | let promise: Bluebird<AccountModel> | ||
44 | if (!host || host === CONFIG.WEBSERVER.HOST) promise = AccountModel.loadLocalByName(accountName) | ||
45 | else promise = AccountModel.loadByNameAndHost(accountName, host) | ||
46 | |||
47 | return isAccountExist(promise, res, sendNotFound) | ||
48 | } | 42 | } |
49 | 43 | ||
50 | async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) { | 44 | async function isAccountExist (p: Bluebird<AccountModel>, res: Response, sendNotFound: boolean) { |
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index f13519c1d..cbf150e53 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts | |||
@@ -38,11 +38,7 @@ async function isVideoChannelIdExist (id: string, res: express.Response) { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | async function isVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { | 40 | async function isVideoChannelNameWithHostExist (nameWithDomain: string, res: express.Response) { |
41 | const [ name, host ] = nameWithDomain.split('@') | 41 | const videoChannel = await VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithDomain) |
42 | let videoChannel: VideoChannelModel | ||
43 | |||
44 | if (!host || host === CONFIG.WEBSERVER.HOST) videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) | ||
45 | else videoChannel = await VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) | ||
46 | 42 | ||
47 | return processVideoChannelExist(videoChannel, res) | 43 | return processVideoChannelExist(videoChannel, res) |
48 | } | 44 | } |